Given a non-negative number represented as an array of digits, add 1 to the number ( increment the number represented by the digits ).
The digits are stored such that the most significant digit is at the head of the list.
NOTE: Certain things are intentionally left unclear in this question which you should practice asking the interviewer. For example: for this problem, following are some good questions to ask :
First argument is an array of digits.
Return the array of digits after adding one.
[1, 2, 3]
[1, 2, 4]
Given vector is [1, 2, 3]. The returned vector should be [1, 2, 4] as 123 + 1 = 124.
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a question? Checkout Sample Codes for more details.