Factor Combinations - Problem
Numbers can be regarded as the product of their factors. For example, 8 = 2 × 2 × 2 = 2 × 4.
Given an integer n, return all possible combinations of its factors. You may return the answer in any order.
Note: The factors should be in the range [2, n - 1].
Input & Output
Example 1 — Basic Case
$
Input:
n = 12
›
Output:
[[2,6],[2,2,3],[3,4]]
💡 Note:
12 can be factored as 2×6, 2×2×3, or 3×4. All factors must be in range [2, 11]
Example 2 — Single Factor Pair
$
Input:
n = 8
›
Output:
[[2,4],[2,2,2]]
💡 Note:
8 can be factored as 2×4 or 2×2×2
Example 3 — Prime Number
$
Input:
n = 37
›
Output:
[]
💡 Note:
37 is prime, so it has no factors in range [2, 36]
Constraints
- 1 ≤ n ≤ 107
- Factors must be in range [2, n-1]
Visualization
Tap to expand
Understanding the Visualization
1
Input
Given number n = 12
2
Process
Find all ways to multiply factors to get 12
3
Output
Return all valid factor combinations
Key Takeaway
🎯 Key Insight: Use backtracking to systematically explore all valid factor combinations while avoiding duplicates
💡
Explanation
AI Ready
💡 Suggestion
Tab
to accept
Esc
to dismiss
// Output will appear here after running code