implemented the longest palindrome algorithm