Talentd
FleetCode

254. Factor Combinations

Medium50.5% acceptance2 companiesPremium elsewhere, free here

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 = 1
Output: []

Example 2:

Input: n = 12
Output: [[2,6],[3,4],[2,2,3]]

Example 3:

Input: n = 37
Output: []

Constraints:

  • 1 <= n <= 107

Asked at 2 companies

3:55
Still stuck?Read the written solution, or watch a walkthrough.
Open solution

Similar problems

Combination SumMedium
Loading editor…
1class Solution:
2 def solve(self):
3 pass
4
Starter codePython 3Spaces: 4
Examples
Input
1
Input
12
Input
37
Your code is saved on this device.Solution