C solution


  • 0
    F
    int reverse(int x) {
        if(x==0){return 0;}
        long long result = 0;
        while(abs(x)>0){
           result = result*10+x%10;
            x /= 10;
        }
        if(result>INT32_MAX||result<INT32_MIN)return 0;
        return result;
    }
    

Log in to reply
 

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