Longest Palindromic Substring
Given a string s, return the longest palindromic substring in s.
Longest Palindromic Substring
Given a string s, return the longest palindromic substring in s.
Example 1
Input: s = "babad" Output: "bab"
Example 2
Input: s = "cbbd" Output: "bb"
Show hint
For each character, expand around it to check for palindromes (odd and even length). Keep track of the longest palindrome found.
Sign in to submit, save progress and mark problems as solved. You can still run your code.
Loading editor...
s =
"babad"
Expected
"bab"