Amazon interview question

palindrome question from the leetcode