My simple Python solution


  • 0
    N
    n = len(digits)
    for i in range(n):
        digits[n-1-i] = (digits[n-1-i] + 1) % 10
        if digits[n-1-i] != 0:
            return digits
    digits.insert(0, 1)
    return digits

Log in to reply
 

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