Math Fundamentals18 sections · 814 units
Open in Course

Problem - Combination Sum

Target sum with reuse

Given an array of distinct integers and a target number, return all unique combinations where the chosen numbers sum to the target. You may use the same number multiple times.

For example, if candidates =[2,3,6,7]= [2, 3, 6, 7] and target =7= 7, the answer is [[2,2,3],[7]][[2, 2, 3], [7]]. Notice you can use 22 twice.

This combines the combination-building pattern you just learned with a sum constraint. The twist: numbers can repeat.