Combination Sum
Medium
Topics
Given distinct positive integers candidates and a target, return all unique combinations that sum to target. A candidate may be reused unlimited times.
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]]
Constraints
- 1 <= candidates.length <= 30
- All candidates are distinct positive integers.
- 1 <= target <= 40
Run ⌘' · Submit ⌘⏎