Dsa
Recursion
Medium
Sum of Combinations
Given a list of positive integers, find all unique combinations of numbers that sum up to a target value. Each number can only be used once in the combination, but the order of combinations does not matter.
Input:
The first line contains a space-separated list of positive integers. The second line contains a single integer target.
Output:
Print each unique combination that adds up to the target on a new line, in ascending order.
Example:
Input:
2 3 6 7
7
Output:
[7]
[2, 2, 3]
Key concepts
recursioncombinatoricsbacktracking
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