Combination Sum II
Given a collection of candidate numbers candidates and a target number target, return all unique combinations in candidates where the candidate numbers sum to target.
Each number in candidates may be used at most once in each combination.
The solution set must not contain duplicate combinations. You may return the combinations in any order.
Example 1
Input
candidates = [10,1,2,7,6,1,5], target = 8Output
[[1,1,6],[1,2,5],[1,7],[2,6]]The unique combinations that sum to 8 are [1, 1, 6], [1, 2, 5], [1, 7], and [2, 6].
Example 2
Input
candidates = [2,5,2,1,2], target = 5Output
[[1,2,2],[5]]The unique combinations that sum to 5 are [1, 2, 2] and [5].
Constraints
- 1 <= candidates.length <= 100
- 1 <= candidates[i] <= 50
- 1 <= target <= 30