Smallest and Largest Numbers with a Digit Product
Updated
Problem statement
Consider positive whole numbers that do not contain the digit 1 (or 0) and whose digits multiply to product.
Return an array [smallest, largest] with the smallest and the largest such numbers, written as strings because they can be long. If no such number exists, return an empty array.
Function
extremeNumbers(product: int) → String[]Examples
Example 1
product = 96return = ["268","322222"]96 = 2 * 2 * 2 * 2 * 2 * 3. The most digits you can get is six, using only the prime digits, and arranging them from largest to smallest gives 322222. The fewest digits is three: 96 = 8 * 6 * 2, and no two digits multiply to 96. In increasing order that is 268.
Example 2
product = 11return = []11 is a prime larger than 9, so no digit product can equal it. The answer is an empty array.
Example 3
product = 36return = ["49","3322"]The fewest digits is two, from 36 = 4 * 9 or 6 * 6; the smaller arrangement is 49. The most digits is four, 3 * 3 * 2 * 2, giving 3322.
Constraints
2 <= product <= 109
More Jane Street Phone Screen questions
- Maximum-Scoring Consecutive Tree LevelsPHONE SCREEN · Seen Nov 2026
- Tree Selection and VisibilityPHONE SCREEN · Seen Nov 2026
- Load/Store Arithmetic InterpreterPHONE SCREEN · Seen Oct 2026
- Instrument Stack Language JumpsPHONE SCREEN · Seen Oct 2026
- Run a Stack Language InterpreterPHONE SCREEN · Seen Oct 2026
- Positive-Integer Expression EvaluationPHONE SCREEN · Seen Oct 2026
- Add Two Integers Given as StringsPHONE SCREEN · Seen Sep 2026
- Angle Between Clock HandsPHONE SCREEN · Seen Jul 2026
- Route Length From Two CyclistsPHONE SCREEN · Seen Jul 2026
- Sort TradesPHONE SCREEN · ONSITE INTERVIEW · Seen Jul 2026
Similar questions at other companies
- Reorderable Task Scheduler With CooldownWaymo · PHONE SCREENWaymo interview questions
- IP Range to CIDR BlocksAirbnb · PHONE SCREENAirbnb interview questions
- Return Exact Cash Register ChangeBank of America · OA
- Smallest Number With a Given Digit SumAmazon · ONSITE INTERVIEW
- Minimum Digit Swaps for the Smallest DifferenceLSEG · OALSEG interview questions
- Maximum Binary Circuit Segregation CostAdobe · OAAdobe interview questions
- Binary CircuitAkuna Capital · OAAkuna Capital interview questions
- Minimize Expression with ParenthesesPinterest · OAPinterest interview questions
- Digit Changes for a Multiple of 9Nutanix · OANutanix interview questions
- Minimize Difference Between Two NumbersMicrosoft · OAMicrosoft interview questions