Add one to a number represented as an array of digits
Description
[1, 2, 3, 4]
. Thus, the array represents the decimal number 1,234.
Given an array of digits that represents a number, add 1 to the number. Suppose an array containing the elements [1, 2, 3, 5]
.
Adding 1 to this would result in the number 1,235 and an array of Ex.
Input : [1, 2, 3, 4]
Output : [1, 2, 3, 5]
Input : [1, 2, 9, 9]
Output : [1, 3, 0, 0]
Input: [9, 9, 9, 9]
Output: [1, 0, 0, 0, 0]