Method
backtrack
(List<List<Integer>> result, List<Integer> temp, int[] candidates, int remain, int start)
Source from the content-addressed store, hash-verified
| 10 | } |
| 11 | |
| 12 | private void backtrack(List<List<Integer>> result, List<Integer> temp, int[] candidates, int remain, int start) { |
| 13 | if (remain < 0) return; |
| 14 | if (remain == 0) { |
| 15 | result.add(new ArrayList<>(temp)); |
| 16 | return; |
| 17 | } |
| 18 | |
| 19 | for (int i = start; i < candidates.length; i++) { |
| 20 | temp.add(candidates[i]); |
| 21 | backtrack(result, temp, candidates, remain - candidates[i], i); |
| 22 | temp.remove(temp.size() - 1); |
| 23 | } |
| 24 | } |
| 25 | } |
Tested by
no test coverage detected