Longest Palindromic Substring

Given a string s, return the length of the longest palindromic substring in s. Pattern focus: Palindrome DP. The problem uses interval expansion or DP to track palindromic ranges.

Input Format

s = input string

Output Format

length of the longest palindromic substring

Constraints

  • 0 <= s.length <= 1000
  • s contains lowercase English letters.

Examples

Example 1:

Input:

s = "babad"

Output:

bab

Explanation:

The longest palindromic substrings have length 3, such as bab or aba.

Example 2:

Input:

s = "cbbd"

Output:

bb

Explanation:

The longest palindromic substring is bb.

Loading...
Longest Palindromic Substring - Dp Strings