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

Starting Python
No results yet.

          
↑↓ move ↵ open esc close

Labs

Loading labs…

Run with your own input

Starting Python

Loading Python…