A palindrome is a word or group of words that remains the same whether you read it forwards from the beginning or backwards from the end: "refer" and "level" are palindromes. Using the FIFO and LIFO strategies, write a function that returns true if a word is palindrome or false if not.
ArrayDeque
Palindrome test
Report a typo
Sample Input 1:
referSample Output 1:
trueWrite a program in Kotlin
fun isPalindrome(word: String): Boolean {
val deque = ArrayDeque<Char>()
for (char in word) {
deque.addLast(char)
}
while (deque.size > 1) {
// make your code here
}
return true
}
___
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.
Create a free account to access the full topic
By continuing, you agree to the JetBrains Academy Terms of Service as well as Hyperskill Terms of Service and Privacy Policy.