Question bank › Backtracking
Dsa Backtracking Medium

Subset Selection with Target Sum

Create a function that finds all possible subsets of integers from a given list that sum up to a target value. The same integer may be used multiple times in a single subset. Implement the solution using backtracking. Input format: - The first line contains an integer N (1 <= N <= 20), the number of integers in the list. - The second line contains N integers separated by spaces. - The third line contains an integer target (1 <= target <= 50). Output format: - Print all unique subsets that sum to the target value. Example: Input: 3 2 3 5 8 Output: [[2, 2, 2, 2], [2, 3, 3], [3, 5]]

Key concepts

backtrackingsubsettarget sum

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
Part of InterviewLab's verified interview question bank. We show the prompt and concepts to practise with — never a copy-paste solution.