class Solution {
public:
int reverse(int x) {
//cout<<x<<endl;
long long ans = 0;
int l = 1;
if(x < 0){
l = -1;
x = -x;
}
while(x > 0){
if(ans * 10 > 2147483647){ ans = 0;break;}
ans = ans*10+x%10;
x/=10;
}
return ans * l;
}
};