Reusable-Candidate Combination Sum
Find every combination of candidates that adds up to target, using each candidate as often as you like.
The problem
Implement Solution.combinationSum(candidates, target). candidates holds distinct positive integers, and you may use each one any number of times. Return every unique combination of candidates whose sum is target. Two combinations are the same if they use the same values the same number of times, so [2, 2, 3] and [3, 2, 2] count once. The combinations and the values inside them can be in any order. For example, candidates = [2, 3, 6, 7] with target = 7 gives [[2, 2, 3], [7]]. There are 1 to 30 candidates, each from 2 to 40, 1 <= target <= 40, and there are fewer than 150 answers.
Starter code
class Solution:
def combinationSum(self, candidates, target):
passPublic examples
candidates = [2, 3, 6, 7], target = 7gives[[2, 2, 3], [7]]candidates = [2], target = 4gives[[2, 2]]candidates = [7, 3], target = 7gives[[7]]
Solving it in the practice book needs an active paid plan.
Open it in the practice bookOne thought at a time.
