Palindrome Number


2018-05-19 02:29:48 by sikoay with 0 comments 1 Hits
Blog 1

恩?

你说啥?

砍了头剁了脚。。。


class Solution(object):
    def isPalindrome(self, x):
        """
        :type x: int
        :rtype: bool
        """
        rate = 10
        if x < 0 :
            return False
        while True:
            if x/rate > 0:
                rate *= 10
            else:
                rate /= 10
                while True:
                    if rate < 10:
                        return True
                    if x/rate != x%10:
                        return False
                    x %= rate
                    x /= 10
                    rate /= 100




Tags:

回复 (0)

Leave a Comment