Share my Python solution with several lines


  • 2
    Z
    class Solution(object):
        def isPalindrome(self, x):
            if x < 0 or (x != 0 and x % 10 == 0):
                return False
            tmp = x
            res = 0
            while(tmp != 0):
                res = res * 10 + tmp % 10
                tmp = tmp / 10
            return res == x

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.