Combination Sum II
Medium · Array, Backtracking
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.
Example 1
Input: candidates = [10,1,2,7,6,1,5], target = 8 Output: [
Example 2
Input: candidates = [2,5,2,1,2], target = 5 Output: [
Constraints
- 1 <= candidates.length <= 100
- 1 <= candidates[i] <= 50
- 1 <= target <= 30
Starter code (python)
class Solution(object):
def combinationSum2(self, candidates, target):
"""
:type candidates: List[int]
:type target: int
:rtype: List[List[int]]
"""
Related problems
- Two Sum (Easy)
- Median of Two Sorted Arrays (Hard)
- Container With Most Water (Medium)
Previous: Search Insert Position · Next: First Missing Positive · All problems
Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.