66. Plus One
easyAsked at IntelGiven an array of digits representing a large integer, increment by one and return the resulting array. Intel asks because the carry-propagation pattern is the same logic that drives big-integer addition in cryptography libraries — including the modular-arithmetic primitives Intel's IPP ships.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Intel loops.
- Glassdoor (2026-Q1)— Intel SWE phone-screen reports cite plus-one as a recurring carry-propagation warm-up.
- GeeksforGeeks (2025-08)— Intel Interview Experience archives reference plus-one with big-integer addition framing.
- LeetCode discuss (2025-12)— Intel-tagged in the LC company-frequency listing.
Problem
You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's. Increment the large integer by one and return the resulting array of digits.
Constraints
1 <= digits.length <= 1000 <= digits[i] <= 9digits does not contain any leading 0's.
Examples
Example 1
digits = [1,2,3][1,2,4]Explanation: The array represents the integer 123. Incrementing by one gives 124.
Example 2
digits = [4,3,2,1][4,3,2,2]Example 3
digits = [9][1,0]Explanation: 9 + 1 = 10, so the array becomes [1, 0].
Approaches
1. Convert to BigInt (brute / not the point)
Join digits to a string, parse as BigInt, add 1, split back to digits.
- Time
- O(n)
- Space
- O(n) for the string buffer
function plusOneBig(digits) {
const big = BigInt(digits.join('')) + 1n;
return big.toString().split('').map(Number);
}Tradeoff: Works in JS thanks to BigInt. Cheats — the problem exists specifically because in many languages, the array IS the only way to handle the integer (it exceeds INT64). Use as a sanity check, never as the final answer.
2. Carry propagation, right-to-left (optimal)
Walk from the last digit. Add 1 (treat as the incoming carry). If digit < 10 after adding, return. If digit == 10, set to 0 and continue carrying. If you fall off the front with a carry, prepend a 1.
- Time
- O(n)
- Space
- O(1) — or O(n) for the new leading-1 array in the all-nines case
function plusOne(digits) {
for (let i = digits.length - 1; i >= 0; i--) {
if (digits[i] < 9) {
digits[i] += 1;
return digits;
}
digits[i] = 0;
}
// All digits were 9. Prepend a 1.
return [1, ...digits];
}Tradeoff: Single pass, optional allocation only when ALL digits were nine. Cache-friendly (sequential access). Same skeleton as big-integer addition in libgmp.
Intel-specific tips
Intel reviewers want the all-nines edge case explicitly identified BEFORE you write code. State: 'There are three cases — last digit < 9 (one increment, return), last digit = 9 (carry up, repeat), all digits = 9 (need a new leading digit).' That preamble shows you've thought about the corner before getting bitten by it. The early-return on digit < 9 is the optimization that Intel reviewers point to — most increments stop at the first iteration.
Common mistakes
- Using `digits[i]++` without checking if < 9 first, then adding mod-10 logic — works but adds unnecessary branches in the common case (no carry).
- Forgetting the all-nines case — returns [0,0,0,...,0] instead of [1,0,0,...,0].
- Using BigInt and missing the point — the problem exists to test carry mechanics, not language features.
- In-place prepend in C/C++ — you'd have to shift all elements right or allocate a new array; mention the allocation cost.
Follow-up questions
An interviewer at Intel may pivot to one of these next:
- Add Binary (LC 67) — same idea, base 2.
- Add Strings (LC 415) — same idea, two operands.
- Plus One Linked List (LC 369) — same logic on a linked list (reverse to walk LSB first, or use recursion).
- What if you needed to add two large numbers represented as digit arrays? (Two-pointer right-to-left with a running carry — same skeleton.)
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why right-to-left instead of left-to-right?
Carries propagate from the least significant digit. Left-to-right would require a second pass to handle the carry. Right-to-left handles it in one pass.
How does this generalize to general big-integer addition?
Walk both digit arrays right-to-left (padding the shorter one with zeros). At each step: sum = a + b + carry; digit = sum % 10; carry = sum >= 10 ? 1 : 0. Continue until both arrays exhausted and carry is 0.
Free learning resources
Curated free links for this problem.
Practice these live with InterviewChamp.AI
Drill Plus One and other Intel interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →