Find the Longest Palindromic Substring

Advanced

Find the Longest Palindromic Substring

A palindrome is a word, phrase, number, or other sequence of characters that reads the same forward and backward (ignoring spaces, punctuation, and capitalization, of course!).

Your mission, if you choose to accept it, is to write a Python function that takes a string and returns its longest palindromic substring. In case of a tie (i.e., multiple substrings of the longest length), you can return any one of them.

Examples:

Let's see some examples to make this clearer:

find_longest_palindrome("babad")

Should return:

"bab" # or "aba" since both are valid palindromic substrings with the maximum length.
find_longest_palindrome("cbbd")

Should return:

"bb" # the longest palindromic substring here is "bb".
find_longest_palindrome("racecar")

Should return:

"racecar" # the entire string is a palindrome with itself.

Challenge yourself

This task can become complex with longer strings, so make sure your approach is efficient. You can try to solve this using dynamic programming for a real learning challenge! Good luck and happy coding!

Geek
Inputs

Arg 1:

"forgeeksskeegfor"
Expected Output
"geeksskeeg"
Actual Output