class Solution {
public:
int reverse(int x) {
int flag=0;
if(x<0)
{
x=x;
flag=1;
}
long long int ans=0;
while(x>0)
{
ans=ans*10+(x%10);
x/=10;
}
if(ans>INT_MAX)return 0;
if(flag==1)ans=ans;
return ans;
}
};
Easy Solution. C++

Yes you are right....I didn't handle that part.....But it some how passes the testcases.....here can be a solution.:
class Solution { public: int reverse(int x) { int flag=0; long long int xx=x; if(xx<0) { xx=xx; flag=1; } long long int ans=0; while(xx>0) { ans=ans*10+(xx%10); xx/=10; } if(ans>INT_MAX)return 0; if(flag==1)ans=ans; return ans; } };