← Back to companies
[ OK ] Loaded —
[ INFO ]
$ cd
$ ls -lt
01
02
03
04
05
$ ls -lt
01
02
03
04
05
user@intervues:~/$
Design a hit counter that counts the number of hits received in the past 5 minutes (300 seconds) and supports variable-length window queries. Implement a HitCounter class with two methods:
You may assume that all calls to hit and getHits are made with non-decreasing timestamps and that timestamps start at 1. The system must efficiently handle a continuous stream of hits and discard data older than any queried window to keep memory bounded.