Longest Palindromic Substring
Return a longest contiguous palindromic substring of s. Any maximum-length answer is valid; these fixtures have a unique maximum.
Example 1
s = "cabbad""abba"Explanation
abba is an even palindrome that cannot extend through its surrounding c and d.
Example 2
s = "racecarx""racecar"Explanation
racecar is an odd palindrome; trailing x cannot extend it.
Example 3
s = "z""z"Explanation
A single character is its own longest palindrome.
Constraints
- 1 <= len(s) <= 1000
- s contains English letters and digits
Function contract
longestPalindromeArguments: jsonSolutionRuns on your device
Loading draft…
Run: 3 examples; Submit: 35 cases, on your device.
"cabbad"