Tuesday, September 9, 2014

Leetcode: Palindrome Number @Python

class Solution:
    # @return a boolean
    def isPalindrome(self, x):
        if x<0:
            return False
        ri=0
        y=x
        while y>0:
            ri=ri*10+y%10
            y=y//10
        return ri==x

No comments :

Post a Comment