【leetcode❤python】66. Plus One

class Solution:  
    # @param digits, a list of integer digits  
    # @return a list of integer digits  
    def plusOne(self, digits):
        
        carry=1
        
        for i in range(len(digits)-1,-1,-1):
            digits[i]+=carry
            if digits[i]>=10:
                digits[i]-=10
                carry=1
            else:
                carry=0
                break
        if i==0 and carry==1:
            digits.insert(0,1)   
            
        
            
        return digits
        

sol=Solution()
print sol.plusOne(digits=[10,10])

上一篇:Jenkins流水线(pipeline)实战之:从部署到体验


下一篇:sysbench数据库压力测试