classSolution { public: intreverse(int x){ int ans = 0; int t = 0; while(x != 0) { t = x % 10; if(ans>214748364||(ans==214748364&&t>7)) { return0; } elseif(ans<-214748364||(ans==-214748364&&t>7)) { return0; } x /= 10; ans = ans * 10 + t; } return ans; } };