Dsa
Recursion
Easy
List Combination Sum
You are given a list of integers and a target integer. Write a program that recursively finds all unique combinations of numbers from the list that sum up to the target. Each number from the list may be used an unlimited number of times in a combination. The output should be a list of combinations, where each combination is represented as a list itself. The order of combinations in the output does not matter.
Input Format:
- The first line contains a space-separated list of integers (the list).
- The second line contains a single integer (the target).
Output Format:
- Print a list of lists, where each list represents a unique combination that adds up to the target.
Example:
Input:
2 3 6 7
7
Output:
[[2, 2, 3], [7]]
Key concepts
recursionbacktrackingcombinations
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