Skip to content

Commit d44ea94

Browse files
clean up 46
1 parent e94d23f commit d44ea94

File tree

1 file changed

+9
-9
lines changed
  • src/main/java/com/stevesun/solutions

1 file changed

+9
-9
lines changed

src/main/java/com/stevesun/solutions/_46.java

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,19 @@
1515
[3,2,1]
1616
]*/
1717
public class _46 {
18-
static class Accepted_solution {
19-
//this solution has a recursive function that has a return type
18+
static class AcceptedSolution {
19+
//this solution has a backtracking function that has a return type
2020
public static List<List<Integer>> permute(int[] nums) {
2121
List<List<Integer>> result = new ArrayList();
2222
List<Integer> init = new ArrayList<>();
2323
result.add(init);
24-
return recursive(result, nums, 0);
24+
return backtracking(result, nums, 0);
2525
}
2626

27-
private static List<List<Integer>> recursive(List<List<Integer>> result, int[] nums,
28-
int pos) {
29-
if (pos == nums.length)
27+
private static List<List<Integer>> backtracking(List<List<Integer>> result, int[] nums, int pos) {
28+
if (pos == nums.length) {
3029
return result;
30+
}
3131
List<List<Integer>> newResult = new ArrayList();
3232
for (List<Integer> eachList : result) {
3333
for (int i = 0; i <= eachList.size(); i++) {
@@ -37,11 +37,11 @@ private static List<List<Integer>> recursive(List<List<Integer>> result, int[] n
3737
}
3838
}
3939
result = newResult;
40-
return recursive(result, nums, pos + 1);
40+
return backtracking(result, nums, pos + 1);
4141
}
4242
}
4343

44-
static class Accepted_solution_with_void_type {
44+
static class AcceptedSolutionWithVoidType {
4545
public static List<List<Integer>> permute(int[] nums) {
4646
List<List<Integer>> result = new ArrayList();
4747
List<Integer> init = new ArrayList<>();
@@ -60,7 +60,7 @@ private static void recursive(List<List<Integer>> result, int[] nums, int pos) {
6060
newResult.add(newList);
6161
}
6262
}
63-
/**You'll have to use the two lines, instead of this line: result = newResult; otherwise, it won't work!!! Fuck!*/
63+
/**You'll have to use the two lines, instead of this line: result = newResult; otherwise, it won't work!!!*/
6464
result.clear();
6565
result.addAll(newResult);
6666

0 commit comments

Comments
 (0)