444. Factor Combinations
Numbers can be regarded as the product of their factors.
- For example, 8 = 2 x 2 x 2 = 2 x 4.
Given an integer n, return all possible combinations of its factors. You may return the answer in any order.
Note that the factors should be in the range [2, n - 1].
Example 1:
Input: n = 12
Output: [[2,6], [3,4], [2,2,3]]
Explanation:
Find valid factorizations using numbers in [2, 11]:
- 12 = 2 × 6
- 12 = 3 × 4
- 12 = 2 × 2 × 3
These are all valid factorizations, so they are included in the output.
Example 2:
Input: n = 1
Output: []
Explanation:
Factors must be in the range [2, n-1], but 1 has no valid factors in this range.
No possible factorization → Output is empty.
Now Your Turn!
Pick the correct output for the given inputInput: n = 8
Still unsure what the problem is asking ?
Let’s go through a few more examples, step by step, to make it clearer.
Constraints:
- 1 <= n <= 107