Python solution with reverse integer

  • 0

    I'm new to Leetcode world, any idea how to run my code faster? Currently only 268ms.

    def isPalindrome(self, x):
        if x < 0:
            return False
        if x == self.reverse(x):
            return True
        return False
    def reverse(self, num):
        res = 0
        while num != 0:
            res = res * 10 + num % 10
            num /= 10
        return res

Log in to reply

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