Time-Based Key-Value Store
Updated
Problem statement
Process timestamped set and get operations on a time-based key-value store.
- A
setstores the supplied value for its key and timestamp and returns"null". - A
getreturns the value for its key with the greatest stored timestamp that is at most the query timestamp. If no such value exists, return the empty string.
Process operations in their array order and return one result per operation.
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 returns the latest value for foo whose stored timestamp does not exceed the query timestamp.
Example 2
operations = ["get","set","get"]keys = ["x","x","x"]values = ["","one",""]timestamps = [2,5,4]return = ["","null",""]Neither query has a stored version at or before its timestamp.
Constraints
1 <= operations.length <= 100000, and all four input arrays have the same length.- Each operation is exactly
"set"or"get". 1 <= key.length, value.length <= 100.1 <= timestamp <= 10^9.- For each key, timestamps supplied to
setare strictly increasing.
More Oracle Phone Screen questions
- Remove Parentheses from a Plus-Minus ExpressionPHONE SCREEN · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Oct 2026
- Shortest Window by Distinct-Value SumPHONE SCREEN · Seen Oct 2026
- Detect a Cycle in a Directed GraphPHONE SCREEN · Seen Oct 2026
- Remove Adjacent Duplicates in String IIPHONE SCREEN · Seen Oct 2026
- Sum Root-to-Leaf Binary NumbersPHONE SCREEN · Seen Oct 2026
- Longest All-Present Attendance StreakPHONE SCREEN · Seen Oct 2026
- Next PermutationPHONE SCREEN · Seen Sep 2026
- Valid ParenthesesPHONE SCREEN · Seen Sep 2026
- Valid Parenthesis StringPHONE SCREEN · Seen Sep 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 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-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
- Time-Based Key-Value StoreVerkada · PHONE SCREENVerkada interview questions