Problem
Return the longest substring of s that is a palindrome (reads the same forwards and backwards). A substring is a contiguous run of characters. Every test here has exactly one longest answer.
Example 1
- Input
- s = "cbbd"
- Output
- "bb"
Example 2
- Input
- s = "racecarxyz"
- Output
- "racecar"
Example 3
- Input
- s = "forgeeksskeegfor"
- Output
- "geeksskeeg"
Constraints
1 <= s.length <= 1000s contains only letters and digits.