Logo
Grokking the Coding Interview: Patterns for Coding Questions
Ask Author
Back to course home

0% completed

Factor Combinations (medium)

Problem Statement

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.

Example 1:

Input: n = 8  
Output: [[2, 2, 2], [2, 4]]   

Example 2:

Input: n = 20  
Output: [[2, 2, 5], [2, 10], [4, 5]]  

Constraints:

  • 1 <= n <= 10<sup>7</sup>

Try it yourself

Try solving this question here:

.....

.....

.....

Like the course? Get enrolled and start learning!