100% fastest code of C code


  • 1
    1

    I only change the type to 'long', the leetcode vm use 64-bit?

    bool isPalindrome(int x) {
        if (x < 0) return false;
        long y=0;
        long xx=x;
        while (xx>0) {
            y = y*10 + xx%10;
            xx/=10;
        }
        return (y == x);
    }

Log in to reply
 

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