Skip to content
playdsa
Preferences

Make yourself comfortable.

Saved on this browser. Your device’s reduced-motion preference is always respected.

Theme
Advanced settings

The Unique Power Set

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Skip equal siblings at one decision depth: The Unique Power Set.

Brute force may pass the demo but fail when the world fills with players.

How you win

  1. 1Recognize when Subsets with duplicates matches the clues
  2. 2Keep this true after every move: no decision depth starts two branches with the same value
  3. 3Reach the result within O(number of unique subsets times n)

Rules and pressure

  • Target cost: O(number of unique subsets times n)
  • State rule: no decision depth starts two branches with the same value
Lesson 1 of 3

Live algorithm trace

Subsets with duplicates

Complete execution
1 of 5
1
choice
2
2
0
1
2

Sort and record the empty subset.

1sort values
2record current path
3for index from start
4if index > start and equals previous: skip
5choose, recurse at index + 1
6undo and return unique paths
sorted = [1,2,2]path = []
Truth to preserve / Cost target
Truth to preserve

no decision depth starts two branches with the same value

Cost target

O(number of unique subsets times n)

Sort equal values together. At one recursive depth, only the first equal sibling may start a branch, while deeper recursion may still take another copy.

Your call · What should guide every step of this algorithm?

Help shape PlayDSA

Something confusing, broken, or missing? Leave a quick note without leaving your lesson.

Please leave out passwords, payment details and other private information.

Page included: /

Sign in to save feedback here, or send it with your email app. Your draft stays here while you sign in.

Open email instead