Which Version Can I See

Easy data structure and algorithm practice puzzle.

A database with snapshot isolation never overwrites a row. Each update writes a new version and marks the old one deleted. Every version is [created, deleted, value], where the first two are transaction numbers and deleted is 0 while the version is still current. A reader with snapshot number s sees a version if it was created at or before s and was not yet deleted at s. Return the value that reader sees, or -1 if the row did not exist for it.

Solve it three ways: snap the jigsaw pieces together, fill in the blanks, or type it from scratch against the tests. This one is free to play, with no account.

Every line of the solution comes with a note explaining why it is there, and a step by step replay shows the code running. At level 3, where you type it yourself, you can ask for an AI mock interview on this problem that ends with a hiring manager's scorecard.

Then grow it into a real project with the Software Engineer button: this puzzle becomes the Event Ranking Service, a pipeline you can run and download. See every Software Engineer project.

More Computer Systems puzzles

All 23 Computer Systems practice problems

Browse all 676 puzzles