Question
Simulate an LFU (least-frequently-used) cache of the given capacity over a list of operations. Each op is ['put', key, value] or ['get', key]. 'get' returns the value or -1 if absent and counts as a use; 'put' inserts/updates and counts as a use. When at capacity and inserting a new key, evict the least-frequently-used key; break ties by least-recently-used among the minimum-frequency keys. If capacity is 0, every put is a no-op. Return the list of results for every 'get' op, in order.
lfu_cache(capacity: int, ops: list[list]) → list[int][2,[["put",1,1],["put",2,2],["get",1],["put",3,3],["get",2],["get",3],["put",4,4],["get",1],["get",3],["get",4]]]out[1,-1,3,-1,3,4]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.