cheetcode

103. Longest Palindromic SubstringMedium

Return the longest contiguous substring that reads the same backward.

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

The runner uses deterministic examples so the expected answer is stable.

Examples

Input: s = "babad"
Output: "bab"
Input: s = "cbbd"
Output: "bb"

Constraints

  • 1 <= s.length <= 1000
  • s consists of English letters and digits.