Longest Palindromic Substring

Medium · Strings · String · Dynamic Programming · Two Pointers

Problem

Return the longest substring of s that reads the same forwards and backwards. If several tie, any one of them is accepted.

Examples

Input: s = "babad"
Output: "bab"

"aba" is equally valid.

Input: s = "cbbd"
Output: "bb"

An even-length palindrome.

Constraints

Approaches

Related problems

Start free on Cariara · Coding problems · System design studio

Coding practice is in SolveMe.Open