Implement TimeMap with set and get. set stores a value for a key at a specific timestamp.
get(key, timestamp) should return the value written at the greatest timestamp less than or equal to the requested timestamp. If no such value exists, return an empty string.
Multiple values can exist for the same key across time, so each key needs its own timestamp history.
Examples
Input: operations = ["TimeMap","set","get","get","set","get","get"], keys = ["","foo","foo","foo","foo","foo","foo"], values = ["","bar","","","bar2","",""], timestamps = [0,1,1,3,4,4,5] Output: [null,null,"bar","bar",null,"bar2","bar2"]
Input: operations = ["TimeMap","set","set","get","get"], keys = ["","love","love","love","love"], values = ["","high","low","",""], timestamps = [0,10,20,5,15] Output: [null,null,null,"","high"]
Constraints
- 1 <= operations.length <= 20,000
- 1 <= key.length, value.length <= 100
- 1 <= timestamp <= 10,000,000
- Timestamps for each key are strictly increasing across set calls.