66. Plus One
from typing import List

class Solution:
    def plusOne(self, digits: List[int]) -> List[int]:
        digits.reverse()

        digits[0] += 1

        rd = 0 # round fromt the previous digit
        for index, d in enumerate(digits):
            if rd+digits[index] > 9:
                digits[index] = digits[index] + rd - 10
                rd = 1
            else:
                digits[index] = digits[index] + rd
                rd = 0

        if rd > 0:
            digits.append(1)

        digits.reverse()

        return digits

def main():
    s = Solution()

    print(s.plusOne([1,2,3]))
    print(s.plusOne([9,9,9]))

if __name__ == '__main__':
    main()