Skip to content

Practice Longest Palindromic Substring

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#5
LeetCode Problem

Longest Palindromic Substring

Problem Statement

Given a string s, return the longest palindromic substring in s.

Source: Longest Palindromic Substring on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
s = "babad"
Output
"bab"

# Example 2

Input
s = "cbbd"
Output
"bb"

Constraints

1 <= s.length <= 1000
s consist of only digits and English letters.

Related LeetCode Problems

Practice more problems similar to Longest Palindromic Substring.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.