Medium
033Longest Palindromic Substring
Return the longest palindromic substring in s. If multiple answers exist, return any one of them.
EXAMPLES
Example 1
Input
{
"s": "babad"
}
Output
"bab"FUNCTION SHAPE
s: string→stringSOLUTION NOTE
Open on LeetCode ↗The worst case is when substrings are palindromes: ie. s = 'aaaaaa'...
Note: there is actually an O(n) solution called Manacher's algorithm, but you aren't expected to know it.