Skip to content

Commit 943b189

Browse files
committed
Update solution 007 [Python3]
1 parent 5d70af4 commit 943b189

File tree

3 files changed

+20
-0
lines changed

3 files changed

+20
-0
lines changed

solution/007.Reverse Integer/README.md

Whitespace-only changes.

solution/007.Reverse Integer/Solution.java

Whitespace-only changes.
+20
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
class Solution:
2+
def reverse(self, x):
3+
"""
4+
:type x: int
5+
:rtype: int
6+
"""
7+
if x==0:
8+
return 0
9+
y=str(abs(x))
10+
y=y[::-1]
11+
y=int(y)
12+
if x<0:
13+
tmp=-y
14+
else:
15+
tmp=y
16+
17+
if tmp>=2**31-1 or tmp<-(2**31):
18+
return 0
19+
else:
20+
return tmp

0 commit comments

Comments
 (0)