class Solution { public: /** * @param n the integer to be reversed * @return the reversed integer */ int reverseInteger(int n) { // Write your code here int flag=1; if(n<0) flag=-1; int tmp=abs(n); int res=0; while(tmp){ res=res*10+tmp%10; tmp=tmp/10; if(res==214748364&&tmp>8){ return 0; } if(tmp&&res>214748364){ return 0; } } return flag*res; } };