API Gateways like Stripe must display "Requests in the last 5 minutes" on their analytics dashboards. Storing every timestamp forever causes Out-Of-Memory crashes. Using a sliding queue dynamically prunes data older than 300 seconds, maintaining a strict upper memory bound.
Design a HitCounter class that tracks the number of API hits. It should support `hit(timestamp)` to record a hit, and `get_hits(timestamp)` to return the total hits in the past 5 minutes (300 seconds). Timestamps are strictly increasing.
βΆ Run Code to test against examples Β· Submit to judge all 5 test cases