Combination Sum
Medium
LC #39
combinationspruningNot attempted yet
You're given a list of distinct positive integers
candidates and a positive target. Return every unique
combination of candidates that adds up to target. The
same candidate may be used any number of times.
Two combinations are the same if they use each number the
same number of times ([2,2,3] and [3,2,2] count
once). Return them in any order.
Example 1
Input: candidates = [2,3,6,7], target = 7
Output: [[2,2,3],[7]]
Example 2
Input: candidates = [2,3,5], target = 8
Output: [[2,2,2,2],[2,3,3],[3,5]]
Example 3
Input: candidates = [2], target = 1
Output: []
Constraints
- 1 ≤ len(candidates) ≤ 30
- 2 ≤ candidates[i] ≤ 40, all distinct
- 1 ≤ target ≤ 40