Solution to check if string is palindrome