File tree 2 files changed +46
-0
lines changed
2 files changed +46
-0
lines changed Original file line number Diff line number Diff line change
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
+ */
Original file line number Diff line number Diff line change
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
+ */
You can’t perform that action at this time.
0 commit comments