algorythms
All Patterns
Pattern 10

Subsets / Combinations

Subsets / Combinations

Build all subsets by starting with an empty set and for each element, creating new subsets by adding it to every existing subset (BFS-style expansion).

Time

O(n · 2ⁿ)

Space

O(n · 2ⁿ)

Recognize it when

  • Generate all subsets / power set
  • Generate all permutations
  • Generate all combinations
  • Count distinct combinations summing to target
Progress0/5
0 solved0 attempted