Combination Sum II
Given a collection of candidate numbers (which may contain duplicates) and a target, return all unique combinations that sum to target. Each number may be used at most once in a combination, and the result must not contain duplicate combinations.
Open official problem prompt ↗Enumerate every distinct multiset of the given numbers that adds up to the target, each occurrence usable once.
Picking coins from a jar to make exact change, but each physical coin can be spent only once and you refuse to write down the same handful twice.
- Input
- candidates = [10,1,2,7,6,1,5], target = 8
- Output
- [[1,1,6],[1,2,5],[1,7],[2,6]]
- Why
- Each listed multiset sums to 8, uses each chosen occurrence once, and no combination is repeated.
1 <= candidates.length <= 1001 <= candidates[i] <= 501 <= target <= 30