1
0
mirror of https://github.com/SunnyQjm/algorithm-review.git synced 2026-06-15 14:04:49 +08:00

Update 1_leetcode7.py

This commit is contained in:
2020-06-20 21:04:00 +08:00
committed by GitHub
parent 44e674a26d
commit c7cfe54639
+1 -1
View File
@@ -33,7 +33,7 @@ class Solution:
1. 首先记录输入值的符号(是正数还是负数),然后取其绝对值|x|进行处理
2. 接着用一个long型(Python里面的数字完全够大)存储结果;
3. 将|x|从个位开始向左遍历,依次叠加到结果里面;
4. 最后判断结果是否出(与32位有符号整形的最大值和最小值进行比对)
4. 最后判断结果是否出(与32位有符号整形的最大值和最小值进行比对)
"""
isNegitive = -1 if x < 0 else 1
result, x = 0, abs(x)