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 Prefix Rescue

Learn
Play
Prove
Problem context and objectives
Mission briefing

Game event engineer · Actions arrive faster than the world can resolve them

Process events in the exact order promised by the data structure: The Prefix Rescue.

The wrong removal order changes gameplay and creates impossible replays.

How you win

  1. 1Recognize when Increasing prefix deque matches the clues
  2. 2Keep this true after every move: deque prefix sums increase and their indices are the only undominated starts
  3. 3Reach the result within O(n)

Rules and pressure

  • Target cost: O(n)
  • State rule: deque prefix sums increase and their indices are the only undominated starts

New words in this mission

Open a term for a plain-language explanation.
invariant+

A statement that must remain true after every meaningful step. It is the safety rule connecting the visual state to correct code.

Lesson 1 of 3

Negative values break an ordinary sliding window. Prefix differences preserve exact sums: the front yields valid spans while the back keeps only undominated starts.

Your call · Prefix 3 minus front prefix 0 is 3. What next?

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