My AC Java Solution


  • 0
    N
    public boolean isPalindrome(int x) {
        int origin = x, reverse = 0;
        while (x != 0) {
            reverse *= 10;
            reverse += x % 10;
            x /= 10;
        }
        return origin < 0 ? false : origin == reverse;
    }

Log in to reply
 

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