/66. Plus One

66. Plus One

Easy
Arrays49.7% acceptance

Given a list of integers number_digits, where each element represents a digit of a non-negative integer in most-significant-to-least-significant order, increment the integer by one and return the resulting list of digits in the same order.

Example 1

Input: [2, 5, 9]

Output: [2, 6, 0]

Explanation: 259 + 1 = 260

Example 2

Input: [7, 9, 9]

Output: [8, 0, 0]

Explanation: 799 + 1 = 800

Example 3

Input: [1, 0, 0, 0]

Output: [1, 0, 0, 1]

Explanation: 1000 + 1 = 1001

Constraints

  • 1 <= len(number_digits) <= 100
  • 0 <= number_digits[i] <= 9 for all i
  • number_digits[0] != 0 (no leading zeros)
Python (current runtime)

Case 1

Input: [3, 4, 5]

Expected: [3, 4, 6]

Case 2

Input: [9, 9, 9]

Expected: [1, 0, 0, 0]

Case 3

Input: [1]

Expected: [2]

Case 4

Input: [5, 0, 0]

Expected: [5, 0, 1]