Reported July 2026
Oraclearray

Add One to a Number Represented as Digits

Reported by candidates from Oracle's online assessment. Pattern, common pitfall, and the honest play if you blank under the timer.

Get StealthCoderRuns invisibly during the live Oracle OA. Under 2s to a working solution.
Founder's read

Oracle reported this one in July 2026, and the input size is the whole point. With up to 200000 digits, you can't parse the array into an integer and add one. No built-in type holds that, and the prompt bans it anyway. It's the classic plus-one problem, an array scan with a carry. If you've got the OA in a day or two, this is a warm-up you can't afford to fumble on edge cases. StealthCoder sits invisibly on your screen as a safety net if you blank mid-assessment, but the logic below is short enough to carry in your head.

The problem

You are given a non-empty integer array digits representing a non-negative decimal integer. The most significant digit appears first, and each array element is one digit.
Add one to the represented integer and return the resulting digit array. Do not convert the entire input to a numeric type or use a dynamic list.
The input has no leading zero unless it represents zero itself.

Function
plusOne(digits: int[]) → int[]

Examples
Example 1
digits = [1,2,9]
return = [1,3,0]
Example 2
digits = [9,9,9]
return = [1,0,0,0]
The carry creates a new most-significant digit.

Constraints
1 <= digits.length <= 200000
0 <= digits[i] <= 9
digits[0] != 0 unless digits.length = 1

Reported by candidates. Source: FastPrep

Pattern and pitfall

Walk the array from the last index backward. If the digit is less than 9, increment it and return immediately, since no carry propagates. If it's 9, set it to 0 and keep moving left. If the loop finishes, every digit was 9, so the answer is a new array of length n+1 with a leading 1 and the rest zeros. That's O(n) time and the only extra space is the one new array in the all-nines case. The common pitfall is forgetting that all-nines case, or converting to a number and overflowing at 200000 digits. Another trap is using a dynamic list or inserting at the front, which the prompt forbids and which costs O(n). Allocate a fixed array of size n+1 instead. Test [0], [9], and [9,9,9] before submitting. If your mind goes blank live, StealthCoder can hand you the loop.

If this hits your live OA and you blank, StealthCoder solves it in seconds, invisible to the proctor.

If this hits your live OA

You can drill Add One to a Number Represented as Digits cold, or you can hedge it. StealthCoder runs invisibly during screen share and surfaces a working solution in under 2 seconds. The proctor sees the IDE. They don't see what's behind it. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it.

Get StealthCoder

Related leaked OAs

⏵ Practice the LeetCode equivalent

This OA pattern shows up on LeetCode as plus one. If you have time before the OA, drill that.

⏵ The honest play

You've seen the question. Make sure you actually pass Oracle's OA.

Oracle reuses patterns across OAs. Built by an Amazon engineer who would have shipped this the night before his JPMorgan OA if he'd had it. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Add One to a Number Represented as Digits FAQ

How hard is the Oracle plus-one OA question really?+

Easy. It's a single backward pass with a carry. The difficulty is in the details: the all-nines case, the single digit [0], and respecting the rule against numeric conversion and dynamic lists. Get those three right and you're done in minutes.

What's the trick to solving it?+

Scan right to left. The first digit below 9 gets incremented and you return right away. Every 9 you pass becomes 0. If you exit the loop, allocate a new array of length n+1, set index 0 to 1, and leave the rest as zeros.

Why can't I just convert the digits to an integer?+

With up to 200000 digits, the value overflows every standard integer type. The problem also explicitly says not to convert the whole input to a numeric type. Doing so would likely fail the tests or violate the stated rules.

What edge cases should I test before submitting?+

Test [0], which should return [1]. Test [9], which returns [1,0]. Test [9,9,9] for the new leading digit. Test something like [1,2,9] for a partial carry, and a large input to confirm the solution is linear, not quadratic.

How do I prepare for this in 48 hours?+

Write the backward loop from memory twice, without looking. Then practice related array-carry problems like adding two digit arrays. Focus on clean handling of the final carry. Pattern recognition matters more than volume here, since this problem is short and well known.

Problem reported by candidates from a real Online Assessment. Sourced from a publicly-available candidate-aggregated repository. Not affiliated with Oracle.

OA at Oracle?
Invisible during screen share
Get it