Skip to main content
All Questions

Build a versioned datastore with timestamped PUT and GET.

Unlock detailed company stats for this questionUpgrade

You are building a versioned datastore with two APIs:

  1. PUT(docId int, contents string, timestamp int): saves the contents of that docId for that timestamp. There can be more than one call per docId with differing timestamps, so versions must be stored per docId.
  2. GET(docId int, timestamp int): for the input timestamp, return the content of that docId for the version just before the timestamp. If there is no content, return an empty string.

PUT timestamps can be unordered, e.g. PUT(1, 'abc', 10), PUT(2, 'bcd', 11), PUT(1, 'cde', 8), PUT(2, 'def', 9) gives GET(1, 5) = '', GET(1, 9) = 'cde', GET(2, 15) = 'bcd'.

Format · One-hour DSA round.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.