dsa · easy
Plus One
Array
You are given a large integer represented as an integer array digits, where each digits[i] is the i-th digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. Increment the large integer by one and return the resulting array of digits.
Arguments
digits— digits of a number, most-significant first; each entry is 0–9
**Example 1:** `` Input: digits = [1,2,3] Output: [1,2,4] ``
Constraints
1 <= digits.length <= 100 Hidden tests include near-max size for this bound; a slower-than-intended solution TLEs.
Examples
Example 1
Input: [1,2,3] Expected: [1,2,4]
Example 2
Input: [9] Expected: [1,0]