Skip to content

Commit 9bac83d

Browse files
committed
fix: result to res
1 parent d25a493 commit 9bac83d

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

java/Backtracking/CombinationsOfSumK.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,16 @@
33

44
public class CombinationsOfSumK {
55
public List<List<Integer>> combinationsOfSumK(int[] nums, int target) {
6-
List<List<Integer>> result = new ArrayList<>();
7-
dfs(new ArrayList<>(), 0, nums, target, result);
8-
return result;
6+
List<List<Integer>> res = new ArrayList<>();
7+
dfs(new ArrayList<>(), 0, nums, target, res);
8+
return res;
99
}
1010

11-
private void dfs(List<Integer> combination, int startIndex, int[] nums, int target, List<List<Integer>> result) {
11+
private void dfs(List<Integer> combination, int startIndex, int[] nums, int target, List<List<Integer>> res) {
1212
// Termination condition: If the target is equal to 0, we found a combination
1313
// that sums to 'k'.
1414
if (target == 0) {
15-
result.add(new ArrayList<>(combination));
15+
res.add(new ArrayList<>(combination));
1616
return;
1717
}
1818
// Termination condition: If the target is less than 0, no more valid
@@ -25,7 +25,7 @@ private void dfs(List<Integer> combination, int startIndex, int[] nums, int targ
2525
// Add the current number to create a new combination.
2626
combination.add(nums[i]);
2727
// Recursively explore all paths that branch from this new combination.
28-
dfs(combination, i, nums, target - nums[i], result);
28+
dfs(combination, i, nums, target - nums[i], res);
2929
// Backtrack by removing the number we just added.
3030
combination.remove(combination.size() - 1);
3131
}

0 commit comments

Comments
 (0)