Minimum Factorization - Problem
Given a positive integer num, return the smallest positive integer x whose multiplication of each digit equals num.
If there is no answer or the answer does not fit in a 32-bit signed integer, return 0.
Note: The result must be composed of digits 2-9 only (no 0 or 1), and we want the smallest possible number.
Input & Output
Example 1 — Basic Factorization
$
Input:
num = 48
›
Output:
68
💡 Note:
48 = 8 × 6. The digits are [8, 6]. Arranging in ascending order gives 68.
Example 2 — Single Digit
$
Input:
num = 9
›
Output:
9
💡 Note:
9 is already a single digit, so the answer is 9 itself.
Example 3 — No Valid Factorization
$
Input:
num = 11
›
Output:
0
💡 Note:
11 is prime and cannot be factored using digits 2-9, so return 0.
Constraints
- 1 ≤ num ≤ 231 - 1
- The result must fit in a 32-bit signed integer
Visualization
Tap to expand
Understanding the Visualization
1
Input
Given number to factorize
2
Factor
Find digit factors 2-9
3
Arrange
Sort factors ascending for minimum result
Key Takeaway
🎯 Key Insight: Factor greedily from largest to smallest digits, then arrange result in ascending order for minimum value
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code