class Solution {
public int reverse(int x) {
long result = 0;
while(x != 0){
long low = x%10;
x = x/10;
result = result * 10 + low;
}
// [-2^31,2^31-1]
if(result > Integer.MAX_VALUE || result < Integer.MIN_VALUE) return 0;
return (int)result;
}
}