Design a hit counter that tracks the number of hits received within the past
Implement the HitCounter class:
HitCounter() Initializes the hit counter system.
void hit(int timestamp) Records a hit that occurred at the given timestamp (in seconds). Multiple hits may occur at the same timestamp.
int getHits(int timestamp) Returns the total number of hits received in the past timestamp (i.e., over the time interval from timestamp timestamp, inclusive).
Constraints:
timestamp
All calls to the system are made in chronological order (i.e., timestamp is monotonically increasing).
At most hit and getHits.
Design a hit counter that tracks the number of hits received within the past
Implement the HitCounter class:
HitCounter() Initializes the hit counter system.
void hit(int timestamp) Records a hit that occurred at the given timestamp (in seconds). Multiple hits may occur at the same timestamp.
int getHits(int timestamp) Returns the total number of hits received in the past timestamp (i.e., over the time interval from timestamp timestamp, inclusive).
Constraints:
timestamp
All calls to the system are made in chronological order (i.e., timestamp is monotonically increasing).
At most hit and getHits.