7. Plus One
easyAsked at AdobeGiven a non-empty array of digits representing a non-negative integer, increment it by one. Adobe uses this to test carry-propagation logic — the same pattern that drives big-integer arithmetic in PDF page-number generation and version counters.
By Sam K., Founder, InterviewChamp.AI · Last verified
Source citations
Public interview reports confirming this problem appears in Adobe loops.
- Glassdoor (2026-Q1)— Adobe phone screens use this for easy array warm-ups.
- LeetCode Discuss (2025-06)— Adobe SDE-I rounds occasionally include this.
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 = [4,3,2,1][4,3,2,2]Example 3
digits = [9][1,0]Explanation: 9 + 1 = 10.
Approaches
1. Convert to BigInt, add, convert back
Join digits, parseInt, add 1, split back.
- Time
- O(n)
- Space
- O(n)
function plusOne(digits) {
const n = BigInt(digits.join('')) + 1n;
return n.toString().split('').map(Number);
}Tradeoff: Works but defeats the point — Adobe wants you to write the carry logic by hand.
2. Right-to-left carry propagation
Walk from the right; add 1 to the last digit; carry while 10; prepend 1 if needed.
- Time
- O(n)
- Space
- O(1) extra (O(n) only when all 9s)
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: Beautiful: single pass, early-exit when no carry. The only O(n) case is [9,9,...,9] → [1,0,0,...,0]. Adobe interviewers love the early return.
Adobe-specific tips
Adobe particularly values the early-exit pattern here — most numbers don't carry through every digit, so the loop usually terminates fast. Mention this maps to how PDF version counters increment across millions of saves without re-allocating each time.
Common mistakes
- Forgetting to handle the all-9s case where a new digit prepends.
- Walking left-to-right — makes carry propagation awkward.
- Converting to Number (not BigInt) on arrays >15 digits — silently loses precision.
Follow-up questions
An interviewer at Adobe may pivot to one of these next:
- Add Two Numbers as linked lists (LC 2).
- Add Strings (LC 415) — same carry logic on character arrays.
- Multiply Strings (LC 43) — extension to multiplication.
Solve it now
Free. No sign-up. Python and JavaScript run instantly in your browser.
FAQ
Why right-to-left?
Addition propagates carry from least significant to most. Walking right-to-left matches the math and lets you stop as soon as a digit doesn't carry.
Can I always early-return when digits[i] < 9?
Yes — at that point the carry is absorbed and no further digit changes. This is exactly why the algorithm is amortized O(1) in many real workloads.