Skip to content

Commit 1dc03bc

Browse files
authored
36ms
1 parent d893c31 commit 1dc03bc

File tree

1 file changed

+5
-0
lines changed

1 file changed

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

0 commit comments

Comments
 (0)