my answer with C


  • 0
    S

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


Log in to reply
 

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