Easy Python


  • 0
    class Solution(object):
        def plusOne(self, digits):
            """
            :type digits: List[int]
            :rtype: List[int]
            """
            forward = 1
            for i in range(len(digits))[::-1]:
                forward, digits[i] = (digits[i] + forward) / 10, (digits[i] + forward) % 10
                if forward == 0:
                    return digits
            return [forward] + digits
    

Log in to reply
 

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