Skip to main content

7. Plus One

easyAsked at Intuit

Given an array of digits representing a large integer, increment by one and return the resulting array. Intuit asks this to gauge whether you can manage carries cleanly — relevant for arbitrary-precision currency math where you can't trust a 64-bit int.

By Alex Chen, Founder, InterviewChamp.AI · Last verified

Source citations

Public interview reports confirming this problem appears in Intuit loops.

  • Glassdoor (2025-11)Intuit screen, framed as 'how would you implement BigInt arithmetic for huge amounts?'
  • LeetCode Discuss (2026-Q1)Intuit phone-screen problem cited.

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 zeros. Increment the large integer by one and return the resulting array of digits.

Constraints

  • 1 <= digits.length <= 100
  • 0 <= digits[i] <= 9
  • digits does not contain any leading 0's.

Examples

Example 1

Input
digits = [1,2,3]
Output
[1,2,4]

Example 2

Input
digits = [4,3,2,1]
Output
[4,3,2,2]

Example 3

Input
digits = [9]
Output
[1,0]

Explanation: Carry propagates: 9 + 1 = 10.

Approaches

1. Convert to BigInt, add 1, convert back

Join digits to a string, BigInt, add 1n, split back into digits.

Time
O(n)
Space
O(n)
function plusOne(digits) {
  const n = BigInt(digits.join('')) + 1n;
  return [...n.toString()].map(Number);
}

Tradeoff: Relies on language BigInt support. Works but doesn't demonstrate carry mechanics — interviewers want to see those.

2. Single-pass carry propagation (optimal)

Walk from rightmost digit. Add 1. While carry, set digit to 0 and propagate. If carry escapes the leftmost digit, prepend 1.

Time
O(n)
Space
O(1) extra (or O(n) if 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;
  }
  // all were 9s; need to prepend 1
  digits.unshift(1);
  return digits;
}

Tradeoff: O(n) in the worst case [9,9,9,...] when carry propagates fully. Otherwise early-exits when a digit is < 9.

Intuit-specific tips

Intuit grades this on the [9,9,9] edge case — many candidates handle the middle carry but forget the array-extension when carry escapes the leftmost. Talk through that case before coding. Bonus signal: connect to fractional-cent arithmetic — when you store $0.01 as integer cents, you don't need this, but for tax computations exceeding 2^53 cents (rare but real for some IRS aggregate filings) you'd use BigInt or digit arrays.

Common mistakes

  • Forgetting digits.unshift(1) when all digits are 9 — returns [0,0,0] instead of [1,0,0,0].
  • Walking left-to-right instead of right-to-left — overcomplicates carry.
  • Mutating then re-allocating — wasteful for large inputs.

Follow-up questions

An interviewer at Intuit may pivot to one of these next:

  • Add Two Numbers (LC 2) — linked list version.
  • Multiply Strings (LC 43) — multi-digit multiplication.
  • Implement BigInt addition from scratch.

Solve it now

Free. No sign-up. Python and JavaScript run instantly in your browser.

Output

Press Run or Cmd+Enter to execute

FAQ

Why right-to-left?

Addition is right-to-left because carries propagate that way. Walking left-to-right would require a second pass to handle carries cleanly.

When do real financial systems need this?

Most use 64-bit cents (sufficient for ~92 quintillion dollars). But aggregate tax filings, audit ledgers across all customers, and historical-data exports can exceed that; then you need BigInt or digit-array math.

Practice these live with InterviewChamp.AI

Drill Plus One and other Intuit interview questions under real-loop conditions with instant feedback on your reasoning, complexity claims, and code.

Practice these live with InterviewChamp.AI →