You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
/**Design a hit counter which counts the number of hits received in the past 5 minutes.
2
+
/**
3
+
* 362. Design Hit Counter
4
+
*
5
+
* Design a hit counter which counts the number of hits received in the past 5 minutes.
3
6
4
-
Each function accepts a timestamp parameter (in seconds granularity) and you may assume that calls are being made to the system in chronological order (ie, the timestamp is monotonically increasing). You may assume that the earliest timestamp starts at 1.
7
+
Each function accepts a timestamp parameter (in seconds granularity) and you may assume
8
+
that calls are being made to the system in chronological order (ie, the timestamp is monotonically increasing).
9
+
You may assume that the earliest timestamp starts at 1.
5
10
6
11
It is possible that several hits arrive roughly at the same time.
7
12
@@ -29,55 +34,60 @@ Each function accepts a timestamp parameter (in seconds granularity) and you may
29
34
// get hits at timestamp 301, should return 3.
30
35
counter.getHits(301);
31
36
Follow up:
32
-
What if the number of hits per second could be very large? Does your design scale?*/
37
+
What if the number of hits per second could be very large? Does your design scale?
38
+
*/
39
+
33
40
publicclass_362 {
34
41
35
-
classHitCounter {
36
-
/**
37
-
* Looked at this post: https://discuss.leetcode.com/topic/48758/super-easy-design-o-1-hit-o-s-gethits-no-fancy-data-structure-is-needed,
38
-
* I added one more field k to make it more generic.
0 commit comments