Dsa
Recursion
Medium
Find All Combinations of a Set
Given a set of distinct integers, return all possible subsets (the power set) of the set. The output should include subsets in increasing order of their size.
Input format:
- A single line of space-separated integers, representing the set of integers. (1 <= len(set) <= 20)
Output format:
- Print each subset on a new line.
Example:
Input:
1 2 3
Output:
[]
[1]
[2]
[3]
[1, 2]
[1, 3]
[2, 3]
[1, 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