Reported October 2026
ElevenLabsgreedy

Next Number with Disjoint Digits

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

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

The ElevenLabs OA reported in October 2026 looks like a simple "next number" question until a digit blocks your obvious answer. You get a 32-bit n and need the smallest larger integer that shares no digit with n. The hinted pattern is union-find, but the real work is greedy digit construction over the allowed set. Examples like 654321 to 700000 and 98 to 100 show where people slip. If you blank under the timer, StealthCoder runs invisibly on your screen as a safety net, so one missed edge case doesn't end the attempt.

The problem

Given a positive 32-bit integer n, find the smallest integer strictly greater than n whose decimal digits do not occur anywhere in the decimal representation of n.
Repeated digits are allowed in the result. Return -1 when no qualifying integer fits in a signed 32-bit integer.

Function
nextDisjointDigitNumber(n: int) → int

Examples
Example 1
n = 654321
return = 700000
Digits 0, 7, 8, and 9 are allowed. The smallest allowed six-digit number above n is 700000.
Example 2
n = 98
return = 100
The result cannot contain 9 or 8; 100 is the first greater number using only allowed digits.

Constraints
1 <= n < 2^31 - 1.
The result, when it exists, is at most 2^31 - 1.
Leading zeroes are not part of a decimal representation.

Reported by candidates. Source: FastPrep

Pattern and pitfall

Don't brute-force n+1 upward. The gap can be huge. Instead, compute the allowed digit set (digits 0-9 minus those in n). If it's empty, return -1. Try the same length first: walk left to right, keep a prefix that matches n only while allowed, and at some position place the smallest allowed digit strictly greater than n's digit, then fill the rest with the smallest allowed digit. Since n's own digits are banned, a prefix can never match, so the first digit must already exceed n's first digit. If no allowed digit beats it, go to length+1: the smallest nonzero allowed digit first, then the smallest allowed digit (including 0) repeated. The pitfall is 0 as a leading digit and overflow past 2^31-1, so check the final value. Union-find doesn't help here, so ignore the hint. StealthCoder is your hedge if the length rollover logic slips live.

Drill it cold or hedge it with StealthCoder. Either way, don't walk into the OA hoping you remember the trick.

If this hits your live OA

You can drill Next Number with Disjoint 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. Made for the candidate who got the OA invite this morning and has 72 hours, not six months.

Get StealthCoder

Related leaked OAs

⏵ The honest play

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

ElevenLabs reuses patterns across OAs. Made for the candidate who got the OA invite this morning and has 72 hours, not six months. Works on HackerRank, CodeSignal, CoderPad, and Karat.

Next Number with Disjoint Digits FAQ

What's the trick in Next Number with Disjoint Digits?+

Build the answer greedily from the allowed digit set instead of searching upward. Since no digit of n is allowed, the first digit must exceed n's first digit, then fill the rest with the smallest allowed digit. If that fails, go one length longer.

Why does the example 98 return 100?+

Digits 9 and 8 are banned, so no two-digit number above 98 works. Moving to three digits, the smallest nonzero allowed leading digit is 1, then the smallest allowed digit 0 fills the rest. That gives 100.

When should the function return -1?+

Return -1 when the allowed set is empty, which happens if n uses all ten digits, or when the constructed result exceeds 2^31 - 1. Check the overflow after building the number, using a 64-bit value or a comparison against the limit.

Is union-find actually needed here?+

No. The hinted pattern doesn't fit this problem as written. It's a digit-construction greedy problem with a set of allowed digits. Spending OA time on a disjoint-set structure would be a wrong turn.

How do I prepare for this in 48 hours?+

Practice the next-greater-number family with digit constraints. Write the same-length case and the length-rollover case separately, then test n=9, n=98, n=654321, and values near 2^31-1. Edge cases like leading zero and overflow are where this one fails.

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

OA at ElevenLabs?
Invisible during screen share
Get it