Solved LeetCode program · 66 of 1,000
#0066 · Plus One
Original English source
The digits is a list of 1, 2, and 3. The position is the last position of digits. The carry is 1.
Repeat while position is at least 0 and carry is 1.
The sum is item position of digits plus carry. Set item position of digits to sum modulo 10. Set carry to sum divided by 10. Set position to one less than position.
For each digit in digits, show digit.
Expected stdout
1 2 4