Skip to content
Veltoryx Technologies
ProProblem 80● MediumLeetCode #40 ↗4 min readUpdated 30 October 2026

Combination Sum II

Find all unique combinations of numbers summing to target where each candidate may only be used once and duplicates exist in the input.

01The problem

Given a collection of candidate numbers (candidates) and a target number (target), find all unique combinations in candidates where the candidate numbers sum to target.

Each number in candidates may only be used once in the combination.

Note: The solution set must not contain duplicate combinations.

InputOutputWhy
candidates = [10, 1, 2, 7, 6, 1, 5], target = 8[[1, 1, 6], [1, 2, 5], [1, 7], [2, 6]]Duplicate 1s used at most once per instance; no duplicate combinations
candidates = [2, 5, 2, 1, 2], target = 5[[1, 2, 2], [5]]Unique combinations

Constraints: 1 <= candidates.length <= 100, 1 <= candidates[i] <= 50, 1 <= target <= 30.

Loading the rest of the lesson…