Problem · String
Longest Palindromic Substring
Learn this problemProblem statement
Heads up! Original problem is from LeetCode 5. Note that in the original problem, a single character is also considered palindromic, so before printing, you just need to check if the length of the longest palindromic substring is 1. Otherwise, follow the original LeetCode problem as is.
Given a String s, return the longest palindromic substring in s.
Function
longestPalindromicSubstring(s: String) → StringExamples
Example 1
s = "babad"return = "bab""aba" is also a valid answer.
Example 2
s = "cbbd"return = "bb"🦊🦊
Constraints
1 <= s.length <= 1000s consist of only digits and English letters.