leetcode9. Palindrome Number

来源:互联网 发布:算法第四版王晓东pdf 编辑:程序博客网 时间:2024/05/22 00:20

Determine whether an integer is a palindrome. Do this without extra space.

class Solution(object):    def isPalindrome(self, x):        """        :type x: int        :rtype: bool        """        ret=0        flag=(x>=0)        if flag==False:            return False        xx=abs(x)        while(xx):            ret=ret*10+xx%10            xx=xx/10        return ret==abs(x)  
0 0
原创粉丝点击