Fast Python solution


  • 0
    B

    '''class Solution(object):
    def plusOne(self, digits):

        digits[len(digits)-1]+=1
        
        for ind in range(len(digits)-1,0,-1):
            if digits[ind]>9:
               digits[ind]=0
               digits[ind-1]+=1
        if digits[0]>9:
           digits[0]=0
           digits=[1]+digits
        
        return digits'''

Log in to reply
 

Looks like your connection to LeetCode Discuss was lost, please wait while we try to reconnect.