254. Factor Combinations
Problem description:
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:
1 | Input: n = 1 |
Example 2:
1 | Input: n = 12 |
Example 3:
1 | Input: n = 37 |
Example 4:
1 | Input: n = 32 |
Solution:
Iterative
1 | class Solution: |
Recursive
1 | class Solution: |
time complexity: $O()$
space complexity: $O()$
reference:
related problem: