# 组合总和 II

<p>给定一个数组&nbsp;<code>candidates</code>&nbsp;和一个目标数&nbsp;<code>target</code>&nbsp;，找出&nbsp;<code>candidates</code>&nbsp;中所有可以使数字和为&nbsp;<code>target</code>&nbsp;的组合。
</p>
<p><code>candidates</code>&nbsp;中的每个数字在每个组合中只能使用一次。</p>
<p><strong>说明：</strong></p>
<ul>
    <li>所有数字（包括目标数）都是正整数。</li>
    <li>解集不能包含重复的组合。&nbsp;</li>
</ul>
<p><strong>示例&nbsp;1:</strong></p>
<pre><strong>输入:</strong> candidates =&nbsp;[10,1,2,7,6,1,5], target =&nbsp;8,<strong><br />所求解集为:</strong>[[1, 7],[1, 2, 5],[2, 6],[1, 1, 6]]</pre>
<p><strong>示例&nbsp;2:</strong></p>
<pre><strong>输入:</strong> candidates =&nbsp;[2,5,2,1,2], target =&nbsp;5,<strong><br />所求解集为:</strong>[[1,2,2],[5]]</pre>

## template

```java
class Solution {
	public List<List<Integer>> combinationSum2(int[] candidates, int target) {
		Arrays.sort(candidates);
		List<List<Integer>> res = new ArrayList<List<Integer>>();
		if (candidates.length == 0 || target < candidates[0])
			return res;
		List<Integer> tmp = new ArrayList<Integer>();
		helper(candidates, target, 0, tmp, res);
		return res;
	}

	public void helper(int[] a, int target, int start, List<Integer> tmp, List<List<Integer>> res) {
		if (target < 0)
			return;
		if (target == 0) {
			res.add(new ArrayList<Integer>(tmp));
			return;
		}
		for (int i = start; i < a.length; i++) {
			tmp.add(a[i]);
			int newtarget = target - a[i];
			helper(a, newtarget, i + 1, tmp, res);
			tmp.remove(tmp.size() - 1);
			if (newtarget <= 0)
				break;
			while (i + 1 < a.length && a[i] == a[i + 1])// 组合中有重复元素，不要重复开头
				i++;
		}
	}
}
```

## 答案

```java

```

## 选项

### A

```java

```

### B

```java

```

### C

```java

```