You are given a list of unique integers candidates and a target integer target. Your goal is to find all possible ways to pick numbers from candidates (repetition allowed) so that the chosen numbers sum exactly to target.
Two selections are considered duplicates if they have identical frequencies of each candidate, irrespective of the order in which they are listed. The final set of combinations can be returned in any sequence, and the ordering of elements within a single combination does not matter.
You are guaranteed that the total number of valid combinations is less than 150.
Example 1:
Input: candidates = [3,4,5], target = 8
Output: [[3, 5], [4, 4]]
Explanation: 3 and 5 sum to 8, and two 4s also sum to 8. No other combination of these numbers can produce 8.
candidates = [3,4, 5] target = 8
[[3,5], [4, 4]]
The input has candidates [3, 4, 5] and target 8.
Example 2:
Input: candidates = [2,3], target = 6
Output: [[2, 2, 2], [3, 3]]
Example 3:
Input: candidates = [7], target = 5
Output: []
Constraints:
1 <= candidates.length <= 302 <= candidates[i] <= 40candidates are distinct.1 <= target <= 40candidates = [3,4, 5] target = 8
[[3,5], [4, 4]]
The input has candidates [3, 4, 5] and target 8.