Practice Real Company Assessment Patterns • Latest 2025–2026 Mock Tests

Programming Exercises

Implement a function to solve the Combination Sum problem (find all unique combinations where candidates sum to a target)

Hard

Problem 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<>(); } }
Log in or sign up to run or submit your code.Log inSign up
Input
candidates = [2, 3, 6, 7], target = 7
Expected Output
[[2, 2, 3], [7]]