123. Combination Sum II — Each Candidate Once
Choose input occurrences whose sum equals the target. You may not reuse an occurrence, but equal values at different input positions can both be chosen.
Different position choices yielding the same value combination must be deduplicated. This differs from the reusable-candidate version of combination sum.
Example 1
Input
nums=[10,1,2,7,6,1,5], target=8
Output
[[1,1,6],[1,2,5],[1,7],[2,6]]
Explanation: Two available 1 occurrences can both appear, while equal sibling starts are suppressed.
Example 2
Input
nums=[2], target=4
Output
[]
Explanation: This occurrence can be chosen only once, unlike DSA-122.
Example 3
Input
nums=[MAX,MAX,1], target=MAX
Output
[[MAX]]
Explanation: Two equal MAX occurrences represent one singleton answer; their combined sum does not wrap into an int.
Constraints
0 <= nums.length <= 201 <= nums[i] <= 231 - 10 <= target <= 231 - 1
Hints
Hint 1
Use the same sibling ownership rule as duplicate subsets.
Hint 2
Each chosen occurrence is consumed, so the child begins after it.
Hint 3
Copy at remaining zero; otherwise skip equal siblings, break on overshoot, recurse from i+1, and undo.
Submissions
Your recent submissions for this problem.
Checking sign-in…
Discussion
Ask a question or share an approach. Posts are public; avoid personal information and mark solution spoilers clearly.
No discussion yet. Start the conversation with a question about this problem.
Checking sign-in…
Run your code to check the sample cases, or submit it to check the full validation suite.
One-use indices coexist with deeper duplicate values
[1,1,2]
3
[[1,2]]