Medium
Design a hit counter that counts hits received in the past 5 minutes (300 seconds). Implement HitCounter(), hit(timestamp) which records a hit at the given timestamp (in seconds), and getHits(timestamp) which returns the number of hits in the past 300 seconds — that is, hits with a recorded time in the range (timestamp - 300, timestamp]. Calls are made in non-decreasing time order.
Input: operations = ["HitCounter","hit","hit","hit","getHits","hit","getHits","getHits"], values = [[],[1],[2],[3],[4],[300],[300],[301]] Output: [null,null,null,null,3,null,4,3]