```
class Solution:
#@param{integer}x
#@return{integer}
def reverse(self,x):
res=0
flag=1
if x<0:
flag=-1
x=(-1)*x
while x>0:
res = res*10+x%10
x = x/10
if res>0x7fffffff:
return 0
return flag*res
```