30. Longest Palindromic Substring
Given a string s, return the longest palindromic substring in s.
A palindromic substring is a contiguous sequence of characters within the string that reads the same forward and backward.
Example 1:
Input: s = "babad"
Output: "bab"
Explanation:
Both "bab" and "aba" are valid palindromic substrings of length 3. Return either.
Example 2:
Input: s = "cbbd"
Output: "bb"
Explanation:
The longest palindrome is "bb" of length 2.
Now Your Turn!
Pick the correct output for the given inputInput: s = "a12321b"
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= s.length <= 1000
- s consists of only English letters (both lowercase and uppercase) and digits.