leetle

Daily challenge for 2025-09-25

268. Design Hit Counter

Design a hit counter which counts the number of hits received in the past 5 minutes (i.e., the past 300 seconds). Your system should accept a timestamp parameter (in seconds granularity), and you may assume that calls are being made to the system in chronological order.

Implement the HitCounter class with hit(timestamp) and getHits(timestamp) methods. Return the number of operations performed.

Example:
Input: operations = ["hit", "hit", "hit", "getHits"], values = [[1], [2], [3], [4]]
Output: 4 (4 operations total)

Run this challenge interactively in Python or JavaScript when the app loads.