Amazon Interview Question

palindrome question from the leetcode