dsa · medium
Hit Counter
GreyOrangeQueueDesign
HitCounter: hit(timestamp), getHits(timestamp) = hits in (t-300, t]. Timestamps non-decreasing.
Fill in the HitCounter class. The starter already walks ops / args and calls your methods — leave the driver at the bottom as-is. Constructors contribute null; booleans print as true / false.
**Example**
`` HitCounter() → null hit(1) → null hit(2) → null hit(3) → null getHits(4) → 3 hit(300) → null getHits(300) → 4 getHits(301) → 3 ``
Constraints
Calls <= 1000
Examples
Example 1
Input: ["HitCounter","hit","hit","hit","getHits","hit","getHits","getHits"] [[],[1],[2],[3],[4],[300],[300],[301]] Expected: [null,null,null,null,3,null,4,3]