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 Transit Ledger

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Separate active trips from route aggregates: The Transit Ledger.

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

How you win

  1. 1Recognize when Underground system design matches the clues
  2. 2Keep this true after every move: each completed trip contributes once to exactly one ordered route aggregate
  3. 3Reach the result within O(1) average per operation

Rules and pressure

  • Target cost: O(1) average per operation
  • State rule: each completed trip contributes once to exactly one ordered route aggregate
Lesson 1 of 3

Live algorithm trace

Underground system design

Complete execution
1 of 5
0
in A@3
op
1
in B@8
2
out C@15
3
out C@22
4
avg A-C

Store rider 1 as active from station A at time 3.

1check-in stores station and time by rider
2check-out removes the active rider
3form the ordered start-end route key
4add duration to route total
5increment route trip count
6average = total / count
rider1 = A@3
Truth to preserve / Cost target
Truth to preserve

each completed trip contributes once to exactly one ordered route aggregate

Cost target

O(1) average per operation

Active riders map to their check-in station and time. Completed route pairs store total duration and trip count, making average queries constant time.

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