Longest Palindromic Substring
MediumDynamic Programming
Decode it first. Clues, constraints, pattern and plan before any code.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.
s = "cbbd" → "bb"
s = "racecarxyz" → "racecar"
s = "forgeeksskeegfor" → "geeksskeeg"Constraints
1 <= s.length <= 1000scontains only letters and digits.