```python def reverse(x): “”” :type x: int :rtype: int “”” maxint=2147483647 ret=x if x < 0: ret=-x while ret > 0 and ret % 10 == 0: ret /= 10 ret=”{}”.format(ret) ret=ret[::-1] ret=int(ret) if x < 0: ret = -ret if ret < -maxint -1 or ret > maxint: ret = 0 return ret
Reverse Integer
Jun 19, 2016