8. Plus One
easyAsked at WorkdayGiven a non-negative integer as a digit array, increment by one and return as a digit array. Workday uses this to test carry-propagation discipline — payroll batch IDs are big integers that increment past JS number precision.
By Alex Chen, Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Workday loops.
- Glassdoor (2025)— Workday SDE1 screen — bigint 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, convert back
BigInt(digits.join('')) + 1n, then split back.
- Time
- O(n)
- Space
- O(n)
return [...(BigInt(digits.join('')) + 1n).toString()].map(Number);Tradeoff: Defeats the purpose — interviewer wants you to handle carry manually.
2. Right-to-left carry
Walk from least significant. If digit < 9, increment and return. Otherwise zero out and carry. If we fall off the front, prepend 1.
- Time
- O(n)
- Space
- O(1) extra (output reuses input)
function plusOne(digits) {
for (let i = digits.length - 1; i >= 0; i--) {
if (digits[i] < 9) {
digits[i]++;
return digits;
}
digits[i] = 0;
}
// Every digit was 9 — e.g., [9,9,9] -> [1,0,0,0]
return [1, ...digits];
}Tradeoff: Single pass, early exit on the first non-9. Only allocates a new array in the all-9s edge case.
Workday-specific tips
Workday grades the [9,9,9] edge case. Many candidates forget to prepend 1 and return [0,0,0]. Walking through this case before coding earns trust. Mention the payroll-batch-ID analogy if the interviewer asks about real-world relevance.
Common mistakes
- Converting to Number — overflows past 15 digits.
- Forgetting the all-9s case (no early return triggered).
- Using digits.unshift(1) — fine semantically but O(n); the [1, ...digits] form makes the allocation visible.
Follow-up questions
An interviewer at Workday may pivot to one of these next:
- Add Binary (LC 67) — same pattern, base 2.
- Add Strings (LC 415) — arbitrary-length integer addition.
- Multiply Strings (LC 43) — extend to multiplication.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why not use BigInt?
The interviewer is testing whether you can implement carry manually. BigInt sidesteps the problem entirely.
Why right-to-left?
Carry propagates from least significant to most significant — same as how you'd add by hand.
Practice these live with InterviewChamp.AI
Drill Plus One and other Workday interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.
Practice these live with InterviewChamp.AI →