Time Based Key-Value Store Medium · Hash Table, String, Binary Search, Design · Software Engineer · Mar 2026
Implement a time-aware key-value store that allows multiple values to be mapped to the same key, each associated with a specific timestamp.
The store should provide two operations:
set(key, value, timestamp): records the given value for the specified key at the provided timestamp.get(key, timestamp): returns the value that was stored for key at the greatest timestamp less than or equal to timestamp. If no such entry exists, return an empty string "".All inputs are valid, and for each individual key the timestamps supplied to set are guaranteed to be strictly increasing.
Example 1:
Input: ["TimeMap","set","get","get","set","get","get"]
[[],["foo","bar",1],["foo",1],["foo",3],["foo","bar2",4],["foo",4],["foo",5]]
Output: [null,null,"bar","bar",null,"bar2","bar2"]
Constraints:
1 <= key.length, value.length <= 1001 <= timestamp <= 10^7set calls are strictly increasing.Company Notes: This problem is known as LeetCode 981 and was reported in an onsite software engineering round in March 2026.