Python Soln timing out

  • 0
    class Solution(object):
        def shortestPalindrome(self, s):
            :type s: str
            :rtype: str
            l = len(s)
            new = s
            for i in range(l):
                new = s[l-i:l][::-1]  + s
                if self.isPalindrome(new):
                    return new
            return new
        def isPalindrome(self, a):
            return a == a[::-1]

Log in to reply

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.