Longest palindromic substring
Given a string, return the longest contiguous substring that reads the same forwards and backwards.
"babad" -> "bab" # "aba" is equally valid
"cbbd" -> "bb"
"a" -> "a"
Return any one longest palindromic substring. The brute force, check all substrings at each, is ; aim for .
Show a hint
Instead of asking "is this substring a palindrome?", fix the center of a candidate palindrome and grow outward. How many possible centers are there?
Your answer
This one is open-ended. Work it through, then check your reasoning against the full solution.