Longest Palindromic Substring
Medium · Two Pointers, String, Dynamic Programming
Given a string s, return the longest palindromic substring in s.
Example 1
Input: s = "babad" Output: "bab"
"aba" is also a valid answer.
Example 2
Input: s = "cbbd" Output: "bb"
Constraints
- 1 <= s.length <= 1000
- s consist of only digits and English letters.
Starter code (python)
class Solution(object):
def longestPalindrome(self, s):
"""
:type s: str
:rtype: str
"""
Related problems
- Longest Substring Without Repeating Characters (Medium)
- Container With Most Water (Medium)
- Roman to Integer (Easy)
Previous: Median of Two Sorted Arrays · Next: Reverse Integer · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.