Simplest code in C


  • 0
    A

    int reverse(int x) {
    long long res = 0;
    while(x) {
    res = res*10 + x%10;
    x /= 10;
    }
    return (res<INT_MIN || res>INT_MAX) ? 0 : res;
    }


Log in to reply
 

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