7. Plus One
easyAsked at AsanaGiven a number represented as a digit array, return the array plus one. Asana uses this to gauge whether you handle carry propagation cleanly — the same pattern that shows up in their counter-aggregation services.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Asana loops.
- Glassdoor (2026-Q1)— Asana new-grad screen warmup.
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]Example 2
digits = [4,3,2,1][4,3,2,2]Example 3
digits = [9][1,0]Approaches
1. Convert to number, add one, back to digits
Parse the array, add one, split back.
- Time
- O(n)
- Space
- O(n)
function plusOne(d) {
const n = BigInt(d.join('')) + 1n;
return String(n).split('').map(Number);
}Tradeoff: Requires BigInt for 100-digit numbers. Asana wants the carry logic in-place.
2. In-place carry propagation
Walk right-to-left, add one, carry while you hit a 9.
- Time
- O(n)
- Space
- O(1) extra
function plusOne(d) {
for (let i = d.length - 1; i >= 0; i--) {
if (d[i] < 9) { d[i]++; return d; }
d[i] = 0;
}
// all 9's: need to prepend 1
return [1, ...d];
}Tradeoff: Early return on the first non-9 digit. The all-9s case is the only allocation.
Asana-specific tips
Asana wants you to handle the all-9s edge case cleanly — the early-return pattern beats the 'always carry' version because it short-circuits. Mention that the same carry pattern shows up in their counter services and you'll get bonus signal.
Common mistakes
- Forgetting the all-9s case (e.g., [9,9,9] -> [1,0,0,0]).
- Iterating left-to-right instead of right-to-left.
- Mutating during iteration in a way that breaks the loop bound.
Follow-up questions
An interviewer at Asana may pivot to one of these next:
- Add two numbers represented as arrays (LC 989).
- Multiply two numbers represented as strings (LC 43).
- What if the digit base isn't 10?
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why right-to-left?
Because carries propagate from least to most significant. Going left-to-right would force you to look ahead for carries, which is harder to write correctly.
Can you avoid the prepend allocation?
Only if you can resize the input array in-place. In JS, [1, ...d] is the cleanest; in C, you'd realloc.
Practice these live with InterviewChamp.AI
Drill Plus One and other Asana interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →