class Solution:
def reverse(self, x: int) -> int:
if x < 0:
x = -x
while x % 10 == 0:
x = x / 10
x = int(x)
x = str(x)
x = list(x)
x.reverse()
x = ''.join(x)
x = int(x)
x=-x
else:
if x != 0:
print(x)
while x % 10 == 0:
x = x / 10
x = int(x)
x=str(x)
x = list(x)
x.reverse()
x = ''.join(x)
x = int(x)
else:
x=0
if x<(-2)**31 or x>(2)**31:
x=0
return x
LeetCode:007.整数反转
猜你喜欢
转载自blog.csdn.net/dosdiosas_/article/details/105681348
今日推荐
周排行