class Solution(object):
def plusOne(self, digits):
"""
:type digits: List[int]
:rtype: List[int]
"""
i=len(digits)-1
while i>=0:
if digits[i]==9:
digits[i]=0
else:
digits[i]+=1
break
i-=1
if i==-1:
return [1]+digits
else :
return digits
参考https://www.youtube.com/watch?v=jtY6cdUU4pI