class Solution(object):
    def longestPalindrome(self, s):
        n=len(s)
        if n==0:
            return ""
        res_length,start,res=1,0,s[0]
        while start<n-1:
            pivot=start+1
            while pivot<n and s[start]==s[pivot]:
                pivot+=1
            left,right=start-1,pivot
            while left>=0 and right<=n-1:
                if s[left]==s[right]:
                    left-=1
                    right+=1
                else:
                    break
            start=pivot
            if right-left-1>res_length:
                res_length,res=right-left-1,s[left+1:right]
        return res
input="caba"
s=Solution()
print(s.longestPalindrome(input))

beat 93%