题目:7. Reverse Integer
链接:https://leetcode.com/problems/reverse-integer/description/
反转给定的整数,如果反转后的结果超出32位整数的范围,返回零。
python:
class Solution(object):
def reverse(self, x):
"""
:type x: int
:rtype: int
"""
res=int(str(x)[::-1]) if x>=0 else -int(str(-x)[::-1])
return res if res<=0x7fffffff and res>=-0x80000000 else 0