Back to DSA
Combination Sum
mediumGiven an array of distinct positive integers (candidates) and a target sum, find all unique combinations of candidates that add up to the target. Each candidate may be used an unlimited number of times. Two combinations are different if they differ in the frequency of at least one chosen number.
Examples
Example 1:
Input:
candidates = [3,5,7], target = 10Output:
[[3,7],[5,5]] Example 2:
Input:
candidates = [2,4,6], target = 8Output:
[[2,2,2,2],[2,2,4],[2,6],[4,4]]Hints
1234567