Add One to List
You are given a list of integers nums
, representing a decimal number and nums[i]
is between [0, 9]
.
For example, [1, 3, 9]
represents the number 139
.
Return the same list in the same representation except modified so that 1
is added to the number.
Constraints
1 ≤ n ≤ 100,000
wheren
is the length ofnums
.
https://binarysearch.com/problems/Add-One-to-List
Examples
Example 1
Input
- nums =
[1, 9, 1]
Output
- answer =
[1, 9, 2]
Example 2
Input
- nums =
[9]
Output
- answer =
[1, 0]
Leave a comment