We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 94503a8 commit 9d29d38Copy full SHA for 9d29d38
.github/Reverseint.py
@@ -0,0 +1,7 @@
1
+class Solution:
2
+ def reverse(self, x):
3
+ range_ = range(-2**31, 2**31-1)
4
+ y = str(abs(x))
5
+ if x == 0 or x not in range_: return 0
6
+ x = int('-' + y[::-1]) if x < 0 else int(y[::-1])
7
+ return x if x in range_ else 0
0 commit comments