Skip to content

Commit 05fc654

Browse files
authored
Create 933.number-of-recent-calls.cpp
1 parent 8a5b995 commit 05fc654

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
#include<deque>
2+
3+
class RecentCounter {
4+
deque<int> req;
5+
public:
6+
RecentCounter() {
7+
req = {};
8+
}
9+
10+
int ping(int t) {
11+
req.push_back(t);
12+
while(req.front() < t-3000) req.pop_front();
13+
return req.size();
14+
}
15+
};
16+
17+
/**
18+
* Your RecentCounter object will be instantiated and called as such:
19+
* RecentCounter* obj = new RecentCounter();
20+
* int param_1 = obj->ping(t);
21+
*/

0 commit comments

Comments
 (0)