cheetcode

140. Plus OneEasy

Add one to a non-negative integer represented as an array of digits.

You are given a large integer represented as an integer array digits, where each digits[i] is a single digit.

Increment the integer by one and return the resulting array of digits.

Examples

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

Constraints

  • 1 <= digits.length <= 100
  • 0 <= digits[i] <= 9
  • The number has no leading zeroes.