Palindrome check in O(n)