981. Time Based Key-Value Store
Create a timebased key-value store class TimeMap, that supports two operations.
set(string key, string value, int timestamp)
- Stores the key and value, along with the given timestamp.
get(string key, int timestamp)
- Returns a value such that set(key, value, timestamp_prev) was called previously, with timestamp_prev <= timestamp.
- If there are multiple such values, it returns the one with the largest timestamp_prev.
- If there are no values, it returns the empty string (“”).
1 | class TimeMap { |