class Solution {
public:
int reverse(int x) {
long long t = 0;
while(x!=0){
t*=10;
t+=x%10;
x/=10;
}
if(t>=INT_MAX)return 0;
if(t<INT_MIN)return 0;
return (int)t;
}
};