Palindrome Number

来源:互联网 发布:天津河东淘宝城 编辑:程序博客网 时间:2024/05/13 20:00

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

class Solution:    # @return a boolean    def isPalindrome(self, x):        if x < 0: return False        k = 1        while x / k >= 10: k *= 10        while x > 0:            if x / k != x % 10: return False            x = (x - x / k * k) / 10            k /= 100        return True                                                                        

0 0