Skip to content

Commit 663a823

Browse files
author
unshun
committed
modify medium-LC75-933
1 parent cee3c0c commit 663a823

File tree

2 files changed

+46
-0
lines changed

2 files changed

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

easy/933. Number of Recent Calls.cpp

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
class RecentCounter {
2+
public:
3+
queue<int> q;
4+
5+
RecentCounter() {
6+
7+
}
8+
9+
int ping(int t) {
10+
q.push(t);
11+
while(q.front() < t-3000){
12+
q.pop();
13+
}
14+
15+
return q.size();
16+
}
17+
};
18+
19+
/**
20+
* Your RecentCounter object will be instantiated and called as such:
21+
* RecentCounter* obj = new RecentCounter();
22+
* int param_1 = obj->ping(t);
23+
*/

0 commit comments

Comments
 (0)