Time Based Key-Value Store
Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp.

30:00

Time Based Key-Value Store
medium
Topics
Companies

Design a time-based key-value data structure that can store multiple values for the same key at different time stamps and retrieve the key's value at a certain timestamp.

Example 1:
Input: {"commands":["TimeMap","set","get","get","set","get","get"],"values":[[],["foo","bar",1],["foo",1],["foo",3],["foo","bar2",4],["foo",4],["foo",5]]}
Output: [null,null,"bar","bar",null,"bar2","bar2"]
Constraints:
  • 1key.length,value.length1001 \leq \text{key.length}, \text{value.length} \leq 100

  • key and value consist of lowercase English letters and digits.

  • 1timestamp1071 \leq \text{timestamp} \leq 10^7

  • All timestamp values of set are strictly increasing.

  • At most 2×1052 \times 10^5 calls in total to set and get.

Input
arr ={"commands":["TimeMap","set","get","get","set","get","get"],"values":[[],["foo","bar",1],["foo",1],["foo",3],["foo","bar2",4],["foo",4],["foo",5]]}

Init TimeMap

Get Key
Timestamp
0
Values for Key ""

Key not found / Empty

Result:

""
Variables
No variables to display
DepthFunction Call
Stack empty
0/28