Skip to content

Commit 66d8dc5

Browse files
authored
Create Reverse Integer.py
1 parent 786b5a4 commit 66d8dc5

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

Python3/Reverse Integer.py

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
class Solution:
2+
def reverse(self, x: int) -> int:
3+
l = list(str(abs(x)))
4+
l.reverse()
5+
rx = int("".join(l)) if x > 0 else -int("".join(l))
6+
return rx if (rx < ((2 ** 31) - 1) and rx > -(2 ** 31)) else 0

0 commit comments

Comments
 (0)