class Solution(object):
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
a = 1
for i in range(len(digits)-1, -1, -1):
digits[i] += a
a = 0
if digits[i]>=10:
a = 1
digits[i] = 0
elif i > 0:
return digits
if a == 1:
digits.insert(0, 1)
return digits
判断是否需要进位,是否超出现在的位数