medium
Combination Sum
Given a set of distinct positive integers and a target, return all unique combinations of those numbers that sum to the target. Each number may be used unlimited times; two combinations are the same if they use the same multiset.
Constraints
- 1 ≤ candidates.length ≤ 30
- 2 ≤ candidates[i] ≤ 40, distinct
- 1 ≤ target ≤ 40
Examples
in: candidates = [2,3,6,7], target = 7
out: [[2,2,3],[7]]
Code it yourself
Solve in
Test execution is not yet available for this exercise.Practice journal →Draft saved in this browser.
Hints:
Which approach applies?
Choose an approach to check your pattern recognition, or reveal the discussion when you need help.