Implement a function to solve the Combination Sum problem (find all unique combinations where candidates sum to a target)
HardProblem Statement
Implement a function to solve the Combination Sum problem (find all unique combinations where candidates sum to a target)
Sample Input
candidates = [2, 3, 6, 7], target = 7
Sample Output
[[2, 2, 3], [7]]
Limits
Time: 2s · Memory: 256 MB
Code Editor
00:00
import java.util.*;
public class Main {
public static List<List<Integer>> combinationSum() {
int[] candidates = {2, 3, 6, 7};
int target = 7;
// Your code here
return new ArrayList<>();
}
}
Input
candidates = [2, 3, 6, 7], target = 7
Expected Output
[[2, 2, 3], [7]]