Reverse Integer(C++) By yangchaojie


  • 0
    Y

    class Solution {
    public:
    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.