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

Learn
Play
Prove
Problem context and objectives
Mission briefing

Puzzle systems engineer · A game mechanic is behaving incorrectly

Store only changes between versions: The Snapshot Ledger.

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

How you win

  1. 1Recognize when Snapshot array matches the clues
  2. 2Keep this true after every move: each index log has at most one final value per snapshot id
  3. 3Reach the result within O(1) set and snap, O(log changes) get

Rules and pressure

  • Target cost: O(1) set and snap, O(log changes) get
  • State rule: each index log has at most one final value per snapshot id

New words in this mission

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

A saved checkpoint of current state. After a crash or reconnect, the system restores this checkpoint instead of rebuilding everything from the beginning.

Lesson 1 of 3

Live algorithm trace

Snapshot array

Complete execution
1 of 5
0
set 0=5
op
1
snap
2
set 0=6
3
get 0@0
4
snap

Record value 5 for the current unsnapped version zero.

1keep a change log per index
2set writes at current snapshot id
3overwrite a same-snapshot change
4snap returns id then increments it
5get binary searches the index log
6return latest value at or before id
currentSnap = 0log0 = [(0,5)]
Truth to preserve / Cost target
Truth to preserve

each index log has at most one final value per snapshot id

Cost target

O(1) set and snap, O(log changes) get

Each index keeps a sorted log of value changes by snapshot id. A get uses binary search for the last change at or before the requested snapshot.

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