Modo entrevista. Cronômetro de 10 min, sem dicas e sem autocompletar
Is the word a palindrome
MédiaStrings10 min
Write a function isPalindromeWord(word) that returns true when word is a palindrome and false otherwise.
wordhas only Latin letters, from 1 to 1000 of them.- The check is case insensitive:
'Racecar','NOON'and'abBA'are palindromes. - A word of one letter is a palindrome.
- Return
trueorfalse.
Tip: at the whiteboard there was no IDE. Try two indexes, one from each end of the word, that move toward each other (two pointers). The tests check only the result.
Exemplos
isPalindromeWord('Racecar')Retorna true
isPalindromeWord('Level')Retorna true
isPalindromeWord('hello')Retorna false
Carregando o editor...
- Entrada
isPalindromeWord('Racecar')Esperadotrue - Entrada
isPalindromeWord('Level')Esperadotrue - Entrada
isPalindromeWord('hello')Esperadofalse
Os testes ocultos rodam no envio