AlgoViz
← All drills
🧠 Drill · Think it through

Every subset of a set

The problem

Given a list of distinct items, return every possible subset — including the empty set and the full set. Notice the shape: the subsets of the whole list are just the subsets of the remaining items, each taken twice — once without the first item, once with it added in. So the problem contains a smaller version of itself, and you solve it by reducing to a list with one fewer item until nothing is left.

Don't jump to code. Walk the four questions an expert asks first — you'll build the habit, not just the answer.

1

Restate it

Before anything else — did you read what's actually being asked? Strip the story to the bare goal.

Strip away the story. What are we actually asked to produce?