7. Plus One
easyAsked at FigmaGiven a non-empty array representing a non-negative integer, increment the number by one. Figma uses this as a 5-minute warm-up to gauge whether candidates handle carry propagation cleanly, the same pattern as their CRDT version-vector increments.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Figma loops.
- LeetCode Discuss (2025-08)— Figma OA easy bucket.
- Glassdoor (2026-Q1)— Warm-up before a longer canvas problem.
Problem
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 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]Example 2
digits = [9,9][1,0,0]Approaches
1. Convert to integer
Parse the digits as a number, add 1, split back to digits.
- Time
- O(n)
- Space
- O(n)
function plusOne(digits) {
const n = BigInt(digits.join('')) + 1n;
return n.toString().split('').map(Number);
}Tradeoff: Works only with BigInt because regular numbers overflow at 100 digits. Cute but misses the point.
2. In-place carry propagation
Walk right-to-left; add 1 with carry; if every digit was 9, prepend a leading 1.
- Time
- O(n)
- Space
- O(1)
function plusOne(digits) {
for (let i = digits.length - 1; i >= 0; i--) {
if (digits[i] < 9) {
digits[i]++;
return digits;
}
digits[i] = 0;
}
return [1, ...digits];
}Tradeoff: Linear, constant extra. Carries only happen when the digit is 9 — early exit otherwise.
Figma-specific tips
Figma uses Plus One to gauge whether you can think about carry propagation cleanly — exactly the mental model their version-vector / Lamport-timestamp increments need. State the invariant 'I either increment and stop, or set to 0 and continue' before writing the loop; that explicit invariant separates competent from confused candidates.
Common mistakes
- Treating digits as a number directly — overflows for n >= 16 digits.
- Forgetting the all-9s case (need to prepend 1).
- Off-by-one when iterating from the wrong end.
Follow-up questions
An interviewer at Figma may pivot to one of these next:
- Add Two Numbers (LC 2) — linked-list version of carry.
- Add Binary (LC 67) — binary variant.
- Multiply Strings (LC 43) — generalize to full arithmetic.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Do I need BigInt?
Only if you go the parse-to-number route. The carry-propagation approach never touches a numeric type, so it scales to any length.
What's the all-9s edge case?
[9,9,9] + 1 = [1,0,0,0]. The loop sets each digit to 0 and falls out without returning, so you prepend a leading 1 at the end.
Practice these live with InterviewChamp.AI
Drill Plus One and other Figma interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →