Question
Design a hit counter that counts hits in the past 300 seconds (a 5-minute window). Operations come in non-decreasing timestamp order: ['hit', t] records a hit at second t; ['get', t] returns the number of hits in the window (t-299, t] inclusive of t, i.e. timestamps strictly greater than t-300. Use O(300) space via circular buckets. Return the list of results for each 'get'.
hit_counter(ops: list[list]) → list[int][[["hit",1],["hit",2],["hit",3],["get",4],["hit",300],["get",300],["get",301]]]out[3,4,3]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.