# [刷题]Combination Sum II

[LintCode]Combination Sum II

public class Solution {
/**
* @param num: Given the candidate numbers
* @param target: Given the target number
* @return: All the combinations that sum to target
*/
public List<List<Integer>> combinationSum2(int[] num, int target) {
// 2015-07-09
// num中可以含重复元素，每个元素只能使用一次
// 解集中不可以含相同的解
List<List<Integer>> rst = new ArrayList<List<Integer>>();
if (num == null || num.length == 0) {
return rst;
}
Arrays.sort(num);
ArrayList<Integer> list = new ArrayList<>();
helper(rst, list, num, target, 0);
return rst;
}

private void helper(List<List<Integer>> rst, ArrayList<Integer> list, int[] num, int t, int pos) {
if (t == 0) {
return;
}
for (int i = pos; i < num.length; i++) {
if (t - num[i] < 0) {
break;
}
if (i != pos && num[i] == num[i - 1]) { // 关键：注意是pos
continue;
}
helper(rst, list, num, t - num[i], i + 1);
list.remove(list.size() - 1);
}
return;
}
}


#### LeetCode40：Combination Sum II

2015-07-06 21:17:58

#### Combination Sum II -- LeetCode

2014-03-13 04:30:39

#### 40. Combination Sum II

2015-07-22 09:20:00

#### [leetcode]40. Combination Sum II ,python实现【medium难度】

2016-06-16 17:37:04

#### 回溯法——combination-sum、combination-sum-ii

2016-05-31 13:27:11

#### 【LeetCode】Combination Sum I & II 解题报告

2014-12-16 11:06:12

#### (Java)LeetCode-40. Combination Sum II

2016-08-11 23:33:03

#### Leetcode 39 Combination Sum & 40 Combination Sum II & 216 Combination Sum III & 377 Combination V

2016-07-26 13:38:06

#### LeetCode40 Combination Sum II 解析

2017-04-06 22:20:53

#### [leetcode] 040. Combination Sum II (Medium) (C++)

2015-08-08 08:33:00