Magicsheet logo

Plus One

Easy
60.7%
Updated 6/1/2025

Plus One

What is this problem about?

The Plus One problem gives you a number represented as an array of digits and asks you to add 1 to it, returning the new digit array. This easy coding problem handles carry propagation from the least significant digit. The array and math interview pattern is the core.

Why is this asked in interviews?

Apple, Uber, Microsoft, Meta, Amazon, TikTok, Google, Bloomberg, and Adobe ask this as a quick implementation problem testing carry propagation and edge cases (all 9s needing an extra digit). Despite being easy, clean handling of the carry chain is the key skill.

Algorithmic pattern used

Reverse carry propagation. Traverse from the last digit: if digit < 9, increment and return. If digit = 9, set to 0 and continue (carry propagates). If all digits were 9 (loop completes without early return), prepend 1: return [1] + [0]*n.

Example explanation

digits=[1,2,9]. Process from right: 9+1=10→set 9 to 0, carry. Next: 2+1=3≤9→set to 3, return. Result: [1,3,0].

digits=[9,9,9]: all become 0, prepend 1: [1,0,0,0].

Common mistakes candidates make

  • Not handling the all-9s case (need to grow the array).
  • Looping from left instead of right.
  • Off-by-one in array length.
  • Using extra conversion to integer (unnecessary and overflows for large arrays).

Interview preparation tip

Plus One tests carry propagation — a fundamental arithmetic operation. The early-return approach is cleaner than tracking a carry variable. Practice variants: "add two numbers represented as arrays," "increment number represented as linked list," "add one to number in place." All use the same right-to-left carry propagation pattern. The edge case (all 9s) is always worth mentioning in interviews.

Similar Questions