Horizontal interview question

Palindrome question and code for the same