FastPrepNext Number with Disjoint Digits
Problems/Next Number with Disjoint Digits

Next Number with Disjoint Digits

ElevenLabs logoElevenLabs● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: The report gives the rule for the smallest greater number, the rule that digits cannot repeat from the original number, the signed-integer limit, the value to return when there is no result, and a worked example. We chose the function signature.

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 = 654321return = 700000

Digits 0, 7, 8, and 9 are allowed. The smallest allowed six-digit number above n is 700000.

Example 2

n = 98return = 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.

More ElevenLabs interview questions

  • Lowest-Cost Shirt Color ScheduleOA · Seen Oct 2026
  • Minimum Magic Stones After MergesOA · Seen Oct 2026
  • Longest Spoken PrefixONSITE INTERVIEW · Seen Nov 2026
  • Dubbing Review Status PropagationONSITE INTERVIEW · Seen May 2025

Similar questions at other companies

  • Unique Digit Permutations Without Leading ZeroMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Signed Digit Partitions Reaching a TargetMeta · PHONE SCREENMeta interview questions
  • Knights, Knaves and Their StatementsSusquehanna International Group (SIG) · OASusquehanna International Group (SIG) interview questions
  • Perfect Squares Matching a PatternNielsen · OA
  • Simplify a Quadratic ExpressionOpenAI · OAOpenAI interview questions
  • String Permutations in Custom Character OrderWex · OA · PHONE SCREEN
  • Vowel Substring GameAkuna Capital · OAAkuna Capital interview questions
  • Minimum Anagram PeriodVisa · OAVisa interview questions
  • Return Exact Cash Register ChangeBank of America · OABank of America interview questions
  • Maximum Equal Parts for PrefixesAmazon · OA
All ElevenLabs interview questionsSee ElevenLabs hiring insights
Saved
class Solution {
    public int nextDisjointDigitNumber(int n) {
        // Write your code here.
    }
}
Checking account…