Design a hit counter (LeetCode Design Hit Counter).
Asked in the onsite coding stage. Reported follow-ups: follow-up questions after the base solution.
Implement hit_counter(operations). Each operation is ["hit", timestamp] or ["getHits", timestamp]. Timestamps are nondecreasing. A hit remains valid while fewer than 300 seconds have elapsed since the oldest currently retained hit. When 300 or more seconds have elapsed, all retained hits expire. Return the results of every getHits operation in order.
def hit_counter(operations):