diff --git a/.github/Reverseint.py b/.github/Reverseint.py new file mode 100644 index 0000000..3b82042 --- /dev/null +++ b/.github/Reverseint.py @@ -0,0 +1,7 @@ +class Solution: + def reverse(self, x): + range_ = range(-2**31, 2**31-1) + y = str(abs(x)) + if x == 0 or x not in range_: return 0 + x = int('-' + y[::-1]) if x < 0 else int(y[::-1]) + return x if x in range_ else 0 \ No newline at end of file