Versioned Document Store
Updated
Problem statement
Maintain versions of named text documents. Process these operations in order:
["CREATE", timestamp, name, text]creates the first version ofnameor overwrites it with a new version at that timestamp.["GET", name]returns the newest text for that document, orNULLwhen it has never been created.["GET_AT", name, timestamp]returns the text from the newest version whose creation timestamp is at most the query timestamp, orNULLwhen no such version exists.
Return the values produced by GET and GET_AT operations in order.
Function
runVersionedDocumentStore(operations: String[][]) → String[]Examples
Example 1
operations = [["CREATE","0","doc","ABC"],["CREATE","3","doc","BCD"],["CREATE","6","doc","CDE"],["GET_AT","doc","1"],["GET_AT","doc","4"],["GET_AT","doc","7"],["GET","doc"]]return = ["ABC","BCD","CDE","CDE"]Each historical lookup selects the latest creation at or before its timestamp. GET returns the newest version.
Constraints
1 <= operations.length <= 200000.- Timestamps are decimal integers in
[0, 10^18]. CREATEtimestamps are strictly increasing for each document name.- Names are non-empty ASCII strings containing no whitespace.
- Text is a printable ASCII string containing neither
|nor a newline. - The total length of returned text is at most
1000000.
More Notion interview questions
- Nested Todo ListPHONE SCREEN · ONSITE INTERVIEW · Seen Sep 2026
- Mutable Table AggregationsPHONE SCREEN · ONSITE INTERVIEW · Seen Apr 2026
- Block Type with the Most ChildrenPHONE SCREEN · Seen Mar 2026
- Country with the Most EventsPHONE SCREEN · Seen Mar 2026
- Event Type with the Most EventsPHONE SCREEN · Seen Mar 2026
- Most Popular Active Plan for the Top Event TypePHONE SCREEN · Seen Mar 2026
- Page Permission InheritancePHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
- Percentage of Blocks Never EditedPHONE SCREEN · Seen Mar 2026
- Text Document HistoryPHONE SCREEN · ONSITE INTERVIEW · Seen Mar 2026
- Top Error Types in a Time WindowONSITE INTERVIEW · Seen Jun 2026
Similar questions at other companies
- Consistent-Hash Packet RouterAmazon · PHONE SCREEN
- Snapshot Map with Sparse Version HistorySnorkel AI · PHONE SCREEN
- Time-Based Key-Value StoreOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
- Time-Based Key-Value StoreCockroach Labs · PHONE SCREEN · ONSITE INTERVIEW
- Time Map with Sum and AverageConfluent · PHONE SCREENConfluent interview questions
- Structured Log Stream with QueriesOpenAI · PHONE SCREENOpenAI interview questions
- Time-Based Key-Value StoreVerkada · PHONE SCREENVerkada interview questions
- Interview Slot BookingTrueFoundry · PHONE SCREEN
- Frequency-Weighted Next-Word SamplingGoogle · PHONE SCREENGoogle interview questions
- Time-Based Key-Value Map With Floor and Ceiling QueriesCharacter.AI · PHONE SCREEN