5. Longest Palindromic Substring

Practice Longest Palindromic Substring for free on NudgeCode: Medium, Dynamic Programming pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

Return the longest contiguous piece of s that reads the same forwards and backwards.

Example

s = "cbbd"    ->  "bb"
s = "banana"  ->  "anana"

If several palindromes tie for longest, any of them is accepted on LeetCode; the tests here only use strings where the longest one is unique.

Constraints