Code Room
CodingMediumcod-g351
Subject Design data structuresLevel Mid–Senior~25 minCommon in Algorithms & data structures interviewsIndustries Software development

Question

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.

Vibe coding: describe the solution in plain language (or narrate it) and the coach grades your approach. Generating runnable code from your description is coming next.

Run or narrate your approach, then ask the coach.