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:
- 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.
- 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

Course
Course
