Dsa
Backtracking
Hard
Combination Sum with Unique Numbers
You are given a list of unique integers and a target sum. Your task is to find all unique combinations of numbers from the list that sum up to the target. Each number can only be used once in each combination, and the combinations should be in ascending order. Print each combination as a list.
Input:
- First line contains an integer n (1 ≤ n ≤ 20), the number of unique integers.
- Second line contains n unique integers.
- Third line contains the target sum (1 ≤ target ≤ 100).
Output:
- Print each unique combination that sums up to the target, one combination per line.
Example:
Input:
4
2 3 6 7
7
Output:
[7]
[2, 3, 6]
Key concepts
backtrackingcombinationsarithmetic
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now