Solution: Combination Sum
Explore how to apply dynamic programming to solve the combination sum problem by generating all unique combinations of numbers that add up to a target. Understand the optimization over naive recursive methods by using a dp table to store and reuse intermediate results, improving both time and space efficiency.
Statement
Given an array of distinct integers, nums, and an integer, target, return a list of all unique combinations of nums where the chosen numbers sum up to the target. The combinations may be returned in any order.
An integer from nums may be chosen an unlimited number of times. Two combinations are unique if the
frequency of at least one of the chosen integers is different.
Constraints:
-
nums.length -
nums[i] -
target