MediumStringsAI interview only
Longest Palindromic Substring
Asked atamazonmicrosoftgooglemetaadobeoracle
01 · Problem
Given a string s, return the longest palindromic substring in s.
A palindrome is a string that reads the same forward and backward.
02 · Examples
Example 01
Input
s = "babad"
Output
"bab"
"bab" is a palindromic substring of length 3. "aba" is also a valid answer.
Example 02
Input
s = "cbbd"
Output
"bb"
"bb" is the longest palindromic substring with length 2.
03 · Constraints
- 011 <= s.length <= 1000
- 02s consist of only digits and English letters.
04 · Optimal complexity
- Time
- O(n^2)
- Space
- O(1)
05 · Two ways to work on it
Practice it alone or rehearse it as an interview.
Practice Mode gives you an editor and test runs, nothing else. AI Interview Mode puts a voice interviewer on the other side, adds a clock, and ends with a scored summary of the round.