Python solution based on recursive method


  • 0
    M
    def isPalindrome(self, x):
        s = str(x)
        def palindrome(s):
            if len(s) == 1 or len(s) == 0:
                return True
            return s[0]==s[-1] and palindrome(s[1:-1])
        return palindrome(s)
    

Log in to reply
 

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