Backtracking Combination Sum Estimated reading: 1 minute 19 views class Solution { public List> combinationSum(int[] candidates, int target) { List> result = new ArrayList<>(); backtrack(result, new ArrayList<>(), candidates, target, 0); return result; } private void backtrack(List> result, List tempList, int[] candidates, int remain, int start) { if (remain < 0) return; if (remain == 0) result.add(new ArrayList<>(tempList)); else { for (int i = start; i < candidates.length; i++) { tempList.add(candidates[i]); backtrack(result, tempList, candidates, remain - candidates[i], i); tempList.remove(tempList.size() - 1); } } } }