class Solution(object):
def reverse(self, x):
isNegative = x < 0
ret = 0
x = abs(x)
while x > 0:
ret *= 10
ret += x % 10
x /= 10
if ret > 1<<31:
return 0

class Solution:
def reverse(self, x):
if x>231-1:
return 0
if x>0 and int(str(x)[::-1])<231-1:
return int(str(x)[::-1])
if x==0:
return 0
if x<0 and int(str(abs(x))[::-1])<2*31-1:
return int(str(abs(x))[::-1])-1
else:
return 0