Zepruv › Coding problems

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

Starter code (python)

class Solution(object):
    def longestPalindrome(self, s):
        """
        :type s: str
        :rtype: str
        """
        

Related problems

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.