class Solution(object):

def reverse(self, x):

"""

The idea is to convert to string and reverse it

:type x: int

:rtype: int

"""

if(x>=0):

ans=str(x)[::-1]

if (int(ans)<2147483647):

return int(ans)

```
if(x<0):
ans=str(x)[::-1]
if (int(ans[:-1]) < 2147483647):
ans=int("-"+ ans[:-1])
return ans
return 0
```