Combinations of a Sum
Medium
Given an integer array and a target value, find all unique combinations in the array where the numbers in each combination sum to the target. Each number in the array may be used an unlimited number of times in the combination.
Example:
Input: nums = [1, 2, 3], target = 4
Output: [[1, 1, 1, 1], [1, 1, 2], [1, 3], [2, 2]]
Constraints:
- All integers in nums are positive and unique.
- The target value is positive.
- The output must not contain duplicate combinations. For example,
[1, 1, 2]and[1, 2, 1]are considered the same combination.