Course · Section 9: Data Structures, Modern Operators and Strings · Lecture 124: Maps: Fundamentals
Design a store that keeps multiple values per key at different timestamps (set calls use increasing timestamps). Implement `TimeMap`: - `set(key, value, timestamp)` stores the value. - `get(key, timestamp)` returns the value with the largest stored timestamp `<= timestamp`, or `''` if none.
+ 1 hidden test run on Submit.
Each key keeps a chronological list; get scans (or binary-searches) for the latest timestamp at or before the query. O(n) per get here; binary search would be O(log n).
Run your code to see results.