less than 1 minute read

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 where n is the length of nums.

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]

Solution

Leave a comment