Example - candidates = [2,3,6,7], target = 7
Input
[2,3,6,7], 7
Output
[[2, 2, 3], [7]]
2+2+3 and 7 are the valid combinations.
Full lesson preview
Find all unique combinations of candidates that sum to a target, allowing repeated use of candidates.
Problem statement
Task
Examples
Input
[2,3,6,7], 7
Output
[[2, 2, 3], [7]]
2+2+3 and 7 are the valid combinations.
Input format
Output format
Constraints
Samples
Input
[2,3,5], 8
Output
[[2, 2, 2, 2], [2, 3, 3], [3, 5]]
All unique combinations that sum to 8.