Implement a hit counter that supports recordHit(timestamp) and getHits(pastSeconds). Use a fixed-size array to maintain a sliding time window (e.g., last 300 seconds) so each operation is O(
-
and memory is bounded. Explain how you handle timestamp collisions within buckets, generalize to arbitrary window sizes, refactor for reusability, and compare trade-offs versus alternatives (queue, deque, hashmap with buckets). Analyze time and space complexity.