leetcode

Workout on LeetCode

View on GitHub

9. Palindrome Number

class Solution:
    def isPalindrome(self, x: int) -> bool:
        y, x0 = 0, x
        while x0 > 0:
            a, x0 = x0 % 10, x0 // 10
            y = 10 * y + a

        return x == y


↥ back to top