Question bank › Recursion
Dsa Recursion Hard

Recursive Subset Sum

Given a list of integers and a target sum, write a program that finds all unique subsets of the list whose elements sum to the target using a recursive approach. Each subset should be printed in a new line in ascending order and should include elements in the same order as they appeared in the input. Input format: - First line contains the target sum. - Second line contains the number of integers in the list. - Third line contains the list of integers. Output format: - Each unique subset that sums to the target. Example: Input: 7 5 2 3 4 7 5 Output: [2, 5] [3, 4] [7]

Key concepts

recursionsubsetsbacktracking

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.