Longest Palindromic Substring
Medium
Strings
Dynamic Programming
Two Pointers
Given a string `s`, return the longest palindromic substring.
Constraints
1 <= s.length <= 1000
s consists of only digits and English letters.
Examples
Example 1:
Input: babad
Output:
Explanation: aba is also valid
Example 2:
Input: cbbd
Output:
Hints
Expand around center for each character.
Consider both odd and even length palindromes.
Tests:
Runtime:
Memory:
Test
Input:
Expected:
Got:
Click Run Code to test against sample cases, or Submit to test against all cases.
▲ Console