Given a string S, identify the longest palindromic substring within S. A palindromic substring is defined as a sequence of characters within S that reads the same forwards and backwards. For example, "racecar" and "level" are palindromic substrings.
Example 1
Input: "abaxyzzyxf"
Output: "xyzzyx"
Explanation: The longest palindromic substring is "xyzzyx" of length 6.
Example 2
Input: "bananas"
Output: "anana"
Explanation: The longest palindromic substring is "anana" of length 5.
Sign in to write, run, and submit your solution against the full test suite.