Code RoomTime based key value store
MediumPrep Room Coding #920

Time based key value store

CodingAlgorithms & data structuresMid–Senior~25 min

Design a time-based key-value store. Process ops: ['set', key, value, timestamp] stores the value for key at the given timestamp (timestamps for a given key are strictly increasing in call order), and ['get', key, timestamp] returns the value whose stored timestamp is the largest one <= the query timestamp, or the empty string '' if none exists. Return the list of get results, in order.

Implement
time_map(ops: list[list]) → list[str]
Examples
in[[["set","foo","bar",1],["get","foo",1],["get","foo",3],["set","foo","bar2",4],["get","foo",4],["get","foo",5]]]out["bar","bar","bar2","bar2"]
What a strong answer looks like

State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.

0:00 of about 25 min
InputExpectedGot
[[["set","foo","bar",1],["get","foo",1],["get","foo",3],["set","foo","bar2",4],["get","foo",4],["get","foo",5]]]["bar","bar","bar2","bar2"]not run yetsample