Description

You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's. Increment the large integer by one and return the resulting array of digits.

Examples

Input:digits = [1,2,3]
Output:[1,2,4]
Explanation:

The result is [1,2,4].

Input:digits = [9,9,9]
Output:[1,0,0,0]
Explanation:

The result is [1,0,0,0].

Input:digits = [1,9,9]
Output:[2,0,0]
Explanation:

The result is [2,0,0].

Constraints

  • 1 ≤ digits.length ≤ 100
  • 0 ≤ digits[i] ≤ 9
  • digits does not contain any leading 0's.

Ready to solve this problem?

Practice solo or challenge other developers in a real-time coding battle!