Reverse digits of an integer.
Example1: x = 123, return 321
Example2: x = -123, return -321
Solution 1:
class Solution {
public:
int reverse(int x)
{
int result = ;
while(x != )
{
if( x > && result > (INT_MAX - x % ) / ||
x < && result < (INT_MIN - x % ) / )
return ;
result = result * + x % ;
x = x / ;
}
return result;
}
};