← All problems

Plus One (digit array)

Easy arraysmath LeetCode ↗
Given a non-empty array of digits representing a large non-negative integer, increment it by one and return the resulting digit array. Handle the all-9s carry case.

Hints (0/3 revealed)

Log in to reveal hints progressively.

Complexity

Time O(n), Space O(1) amortized

Common pitfalls

  • Forgetting the all-9s expansion
  • Converting to int (overflows)

Your solution

Log in to save your code and track progress.