Skip to content

Commit f4b1a1b

Browse files
committed
Merge branch 'master' of github.com:yanglbme/leetcode
2 parents f0f00df + 8093148 commit f4b1a1b

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)