LeetCode 九、判断一个整数是不是回文数。回文数是指正序(从左向右)和倒序(从右向左)读都是同样的整数。

class Solution:
    def isPalindrome(self, x: int) -> bool:
        a = x
        if a<0:
            return False
        else:
            num = 0
            while(a!=0):
                temp = a%10
                a = a//10
                num = num*10+temp
            if num==x:
                return True
            else:
                return False
相关文章
相关标签/搜索