Need help


  • 0
    N

    What is the problem in this code?
    Can anyone explain...
    ...
    class Solution {
    public:
    int reverse(int x) {
    int p=x;
    if(p<0)
    p=-p;
    int res=0;
    while(p>0){
    int rem=p%10;
    res=res*10+rem;
    p=p/10;
    }
    if(x<0)
    res=-res;
    if(res>2147483647 || res<-2147483648)
    return 0;
    return res;
    }
    };
    ...


Log in to reply
 

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