MCPcopy
hub / github.com/qiyuangong/leetcode / combinationSum

Method combinationSum

java/039_Combination_Sum.java:5–13  ·  view source on GitHub ↗
(int[] candidates, int target)

Source from the content-addressed store, hash-verified

3 List<List<Integer>> answer = new ArrayList<List<Integer>>();
4
5 public List<List<Integer>> combinationSum(int[] candidates, int target) {
6 int clen =candidates.length;
7 for (int i = 0; i < clen; i++) {
8 List<Integer> tlist = new ArrayList<Integer>();
9 tlist.add(candidates[i]);
10 backtracking(candidates, i, 1, (target - candidates[i]), tlist);
11 }
12 return answer;
13 }
14 private void backtracking(int[] candidates, int index, int tsize, int target, List<Integer> temp) {
15 if (target == 0) {
16 answer.add(new ArrayList(temp));

Callers

nothing calls this directly

Calls 2

backtrackingMethod · 0.95
addMethod · 0.45

Tested by

no test coverage detected