```
class Solution:
# @return an integer
def reverse(self, x):
s = str(x)
s = s[::-1]
if s[len(s)-1] == '-':
if -int(s[:len(s)-1]) < -math.pow(2,31):
return 0
return -int(s[:len(s)-1])
if int(s) >= math.pow(2,31):
return 0
return int(s)
```