Skip to content

Commit f2ac493

Browse files
authored
Update solution 007 [python2] - 36ms
1 parent 543973d commit f2ac493

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
#36ms with python2
2+
class Solution:
3+
def reverse(self, x):
4+
s = cmp(x,0) #提取此输入数字的符号
5+
r = int(`x*s`[::-1]) #先作为字符串输入,然后转回整型
6+
return r*s * (r<2**31) #防止溢出,小于的情况下返回true,否则为false
7+
8+

0 commit comments

Comments
 (0)