Time Based Key-Value Store
Updated
Problem statement
Process set and get operations on a time-based key-value store. A get returns the value written for that key at the greatest timestamp not exceeding the query timestamp, or the empty string when none exists. Return "null" for set operations.
Function
runTimeMap(operations: String[], keys: String[], values: String[], timestamps: int[]) → String[]Examples
Example 1
operations = ["set","get","get","set","get"]keys = ["foo","foo","foo","foo","foo"]values = ["bar","","","bar2",""]timestamps = [1,1,3,4,4]return = ["null","bar","bar","null","bar2"]Each query sees the most recent value for foo at or before its timestamp.
Constraints
- All four arrays have equal non-zero length.
- Set timestamps for each key are strictly increasing.
- There are at most
100000operations.
More Navan interview questions
- Type-Ahead Prefix MatchesONSITE INTERVIEW · Seen Dec 2024
- Minimum Steps on a Circular Character DialONSITE INTERVIEW · Seen Jan 2024
- Minimum Stick Connection CostONSITE INTERVIEW · Seen Jan 2024
- Shortest Substring with at Least K Distinct CharactersONSITE INTERVIEW · Seen Jan 2024
- Compare N-Ary Tree Leaf SequencesONSITE INTERVIEW · Seen Nov 2023
- Roman to IntegerPHONE SCREEN · Seen Oct 2024
- Sort ColorsPHONE SCREEN · Seen Oct 2024
- Basic CalculatorPHONE SCREEN · Seen Jun 2024
- LRU CachePHONE SCREEN · Seen Jun 2024
- House RobberPHONE SCREEN · Seen May 2024
Similar questions at other companies
- Time-Based Key-Value StoreOracle · PHONE SCREEN · ONSITE INTERVIEWOracle interview questions
- Time-Based Key-Value StoreCockroach Labs · PHONE SCREEN · ONSITE INTERVIEW
- Time-Indexed Key-Value StoreTogether AI · ONSITE INTERVIEW
- Globally Versioned Key-Value StoreLyft · ONSITE INTERVIEWLyft interview questions
- Versioned Key-Value Store with Suffix TruncationNuro · ONSITE INTERVIEWNuro interview questions
- Future-Effective Employee SalaryRippling · ONSITE INTERVIEWRippling interview questions
- Key-Value Store with Hit CounterDatabricks · ONSITE INTERVIEWDatabricks interview questions
- Time-Based Key-Value DatabaseIllumio · ONSITE INTERVIEWIllumio interview questions
- Transaction Event StoreCapital One · ONSITE INTERVIEWCapital One interview questions
- Versioned Social NetworkOpenAI · PHONE SCREEN · ONSITE INTERVIEWOpenAI interview questions