两数相加
2019-04-05 本文已影响0人
冷水调画
if not x:
return 0
str_x = str(x)
start = ''
if str_x[0] == '-':
start = '-'
temp = start + str_x[::-1].lstrip('0').rstrip('-')
output = int(temp)
if -2**31 <= output <= 2**31-1:
return output
else:
return 0
if not x:
return 0
str_x = str(x)
start = ''
if str_x[0] == '-':
start = '-'
temp = start + str_x[::-1].lstrip('0').rstrip('-')
output = int(temp)
if -2**31 <= output <= 2**31-1:
return output
else:
return 0