Combination Sum II Problem
Combination Sum II Problem — ExecCode Medium DSA Practice
Solve the Combination Sum II problem on ExecCode. Free online medium DSA practice in Backtracking. Write and run code in Java, C++, Python — no signup required to run.
Problem description
Given a collection of candidate numbers (which may contain duplicates) and a target number, find all unique combinations where the candidates sum to target. Each number may be used at most once per combination, and the answer must not contain duplicate combinations.
Examples
Input candidates = [10, 1, 2, 7, 6, 1, 5], target = 8; Output [[1, 1, 6], [1, 2, 5], [1, 7], [2, 6]]. Input candidates = [2, 3, 5], target = 8; Output [[3, 5]]. Input candidates = [2, 5, 2, 1, 2], target = 5; Output [[1, 2, 2], [5]]
Constraints
1 <= candidates.length <= 100 1 <= candidates[i] <= 50 1 <= target <= 30
Practice Combination Sum II free on ExecCode. Browse DSA problems, topic map, and placement guides.