The method below receives a large Integer represented by an List of Integers called nums, where each nums[i] is the ith digit of the Integer. These digits are arranged from the most significant to the least significant, from left to right. The large integer has no leading zeros. So, the List [4,5,6]
represents the Integer 456
.
Add one to this large Integer and return the updated list.
Example 1:
Input: nums: [4, 5, 6]
Output: [4, 5, 7]
Explanation: the input represents 456. 456 + 1 = 457. The output is [4, 5, 7]
Example 2:
Input: nums: [1, 2, 3]
Output: [1, 2, 4]
Explanation: the input represents 123. 123 + 1 = 124. The output is [1, 2, 4]
Constraints:
- 1 <= nums.length <= 100
- 0 <= nums[i] <= 9
- nums does not contain any leading 0's