Skip to the editor
JSGroundwork
JSGroundwork handwritten · web dev
←Back to Design problems

Ready to read

JSJavaScript⑂Git◎Interview prepΣDSA in JSSDSystem Design
More topics15›
</>HTML{ }CSS⚛ReactNNext.jsNeNest.jsTSTypeScriptNoNode.js🐳DockerDBSQL & Databases✓Testing🔒Web Security☁Cloud & DevOps◈GraphQL◆Redis☸Kubernetes
☰‹›
Description
All topics›JavaScript›Design problems

Time Based Key-Value Store

advancedlayer A9 · Design problems5 tests

Design a store that keeps every version of a key's value and can be queried as of a point in time.

  • set(key, value, timestamp) — record a value for that key at that time. Timestamps are strictly increasing per key
  • get(key, timestamp) — the value written at the largest stored time that is <= timestamp
  • If the key has no write at or before that time (or does not exist at all), return the empty string ''
  • get must be O(log n) in the number of writes for that key — a backwards linear scan is not good enough

Stuck?

All exercisesPlayground
1234567891011121314
loading the editor…

Nothing yet — hit Run and whatever you log shows up here.

Submit to see how you did.

⌘/Ctrl + Enter run⌘/Ctrl + S save⌘/Ctrl + / comment⌘/Ctrl + F find/replace⌘/Ctrl + D select next matchAlt + click multi-cursorTab indent · ⇧Tab outdentEsc leave fullscreen