0PricingLogin
Competitive Programming Academy · Lesson

Generate All Subsets

Choose or skip each element.

Why Generate Subsets

Many contest tasks ask you to try every subset of a small set. With recursion you can list all of them cleanly and reliably. 🧩

Choose or Skip Each Element

The core idea: for each element you make one binary choice, include it or leave it out. Every full set of choices gives one subset.

All lessons in this course

  1. Think Recursively: Base & Recurse
  2. Generate All Subsets
  3. Permutations and the N-Queens Idea
  4. Prune to Survive the Time Limit
← Back to Competitive Programming Academy