File tree Expand file tree Collapse file tree 1 file changed +6
-7
lines changed
src/main/java/com/fishercoder/solutions Expand file tree Collapse file tree 1 file changed +6
-7
lines changed Original file line number Diff line number Diff line change 6
6
import java .util .Set ;
7
7
8
8
public class _46 {
9
-
10
9
public static class Solution1 {
11
10
public List <List <Integer >> permute (int [] nums ) {
12
11
List <List <Integer >> result = new ArrayList ();
13
12
result .add (new ArrayList <>());
14
- return recursion (nums , 0 , result );
13
+ return recurse (nums , 0 , result );
15
14
}
16
15
17
- private List <List <Integer >> recursion (int [] nums , int index , List <List <Integer >> result ) {
16
+ private List <List <Integer >> recurse (int [] nums , int index , List <List <Integer >> result ) {
18
17
if (index == nums .length ) {
19
18
return result ;
20
19
}
21
20
List <List <Integer >> newResult = new ArrayList <>();
22
- for (List <Integer > eachList : result ) {
23
- for (int i = 0 ; i <= eachList .size (); i ++) {
24
- List <Integer > newList = new ArrayList <>(eachList );
21
+ for (List <Integer > list : result ) {
22
+ for (int i = 0 ; i <= list .size (); i ++) {
23
+ List <Integer > newList = new ArrayList <>(list );
25
24
newList .add (i , nums [index ]);
26
25
newResult .add (newList );
27
26
}
28
27
}
29
28
result = newResult ;
30
- return recursion (nums , index + 1 , result );
29
+ return recurse (nums , index + 1 , result );
31
30
}
32
31
}
33
32
You can’t perform that action at this time.
0 commit comments