File tree Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Expand file tree Collapse file tree 3 files changed +33
-0
lines changed Original file line number Diff line number Diff line change
1
+ public class Solution {
2
+ List <List <Integer >> getFactors (int n , int low , int high ) {
3
+ List <List <Integer >> found = new ArrayList <>();
4
+
5
+ if (low <= n && n < high ){
6
+ found .add (Arrays .asList (n ));
7
+ }
8
+
9
+ for (int i = low ; n / i >= low ; i ++){
10
+ if (n % i == 0 ){
11
+ for (List <Integer > sub : getFactors (n / i , i , n )){
12
+ List <Integer > l = new ArrayList <>();
13
+ l .add (i );
14
+ l .addAll (sub );
15
+ found .add (l );
16
+ }
17
+ }
18
+ }
19
+
20
+ return found ;
21
+ }
22
+
23
+ public List <List <Integer >> getFactors (int n ) {
24
+ return getFactors (n , 2 , n );
25
+ }
26
+ }
Original file line number Diff line number Diff line change
1
+ ---
2
+ layout : solution
3
+ title : Factor Combinations
4
+ date : 2015-08-12 23:03:42+08:00
5
+ leetcode_id : 254
6
+ ---
7
+ {% include_relative README.md %}
You can’t perform that action at this time.
0 commit comments