LeetCode Palindrome Number

class Solution:
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        return int(str(abs(x))[::-1]) == x
        if x < 0:
            return False
        if x < 10:
            return True
        y = x
        res = 0
        while x != 0:
            res = res * 10 + int(x % 10)
            x = int(x / 10)
        if y == res:
            return True
        else:
            return False
return int(str(abs(x))[::-1]) == x

你可能感兴趣的:(LeetCode Palindrome Number)