Plus One

Easy

Topics
ArrayMath

You are given a large integer as an array of digits digits (most significant first). Increment it by one and return the resulting digits.

Example 1

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

Example 2

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

Constraints

  • 1 <= digits.length <= 100
  • 0 <= digits[i] <= 9
  • No leading zeros (except the number 0).
Run ⌘' · Submit ⌘⏎