#=================================== # Tanzila Islam # Email: tanzilamohita@gmail.com # Language: Python 3 #=================================== class Solution: def reverse(self, x: int) -> int: x_str = str(x) if x_str[0] == '-': a = x_str[::-1] rev = int(x_str[0]+a[:-1]) else: rev = int(x_str[::-1]) if rev not in range((-1 << 31), (1 << 31) - 1): return 0 else: return rev
No comments:
Post a Comment