求 数组里 和为s的所有组合
关键在于去重,但是去重的方式也很简单。
public ArrayList<ArrayList<Integer>> combinationSum(int[] candidates,
int target) {
if (candidates == null)
return null;
Arrays.sort(candidates);
boolean[] used = new boolean[candidates.length];
ArrayList<Integer> list = new ArrayList<Integer>();
find(0, target, list, candidates, 0, used);
return cases;
}
ArrayList<ArrayList<Integer>> cases = new ArrayList<Ar......
阅读全文