Given a string s, return the longest contiguous substring of s that is a palindrome. If several palindromic substrings tie for the longest length, return the one that starts earliest in s. This tie-break makes the answer unique.
Characters are case-sensitive: "Aa" is not a palindrome.
Examples
Example 1
Input: s = "babad"
Output: "bab"
Explanation: "bab" and "aba" both have length 3; "bab" starts earlier.
Example 2
Input: s = "cbbd"
Output: "bb"
Constraints
1≤s.length≤1000
s consists of digits and English letters.
Loading editor...
Log in to run your code. Your draft is saved in this browser.Log inSign up