7. Reverse Integer
class Solution:
def reverse(self, x: int) -> int:
sign = x < 0 and -1 or 1
r = str(x * sign)[::-1]
return 0 if (len(r) == 10 and r > str(2**31)) else int(r) * sign
class Solution:
def reverse(self, x: int) -> int:
sign = x < 0 and -1 or 1
r = str(x * sign)[::-1]
return 0 if (len(r) == 10 and r > str(2**31)) else int(r) * sign