class Solution:

```
def reverse(self, x):
numstr = str(x)
newstr = ''
length = len(numstr)
isneg = False
for i in range(0,length):
if numstr[i] == "-":
isneg = True
continue
newstr = numstr[i] + newstr
newstr = int(newstr)
if isneg:
newstr = 0 - newstr
if(abs(newstr) > (2 ** 31)-1):
return 0
return newstr
```