You are given a large integer represented as an integer array digits, where each digits[i] is the i-th digit of the integer. The digits are ordered from most significant to least significant. Increment the large integer by one and return the resulting array of digits.
Constraints: 1 ≤ digits.length ≤ 100 · 0 ≤ digits[i] ≤ 9 · No leading zeros
Given an array of digits representing a large integer, add 1 and return the result as an array. Sounds trivial — just convert to a number, add 1, convert back.
Before we try that, let's see if you can spot the danger. Here's a 20-digit number — nothing but nines.
20 digits — each one is 9.