Skip to content

Commit e8b9f5c

Browse files
committed
committed from zkp
1 parent 8921ee0 commit e8b9f5c

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

LeetCode/Reverse.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
class Solution:
2+
def reverse(self, x):
3+
"""
4+
:type x: int
5+
:rtype: int
6+
"""
7+
t = abs(x)
8+
a = int(str(t)[::-1])
9+
if x < 0:
10+
a = -a
11+
L = pow(-2,31)
12+
R = pow(2,31)-1
13+
if (a > R) or(a < L):
14+
return 0
15+
return a

0 commit comments

Comments
 (0)