0933.cpp (184B)
1 class RecentCounter { 2 queue<int> q; 3 4 public: 5 int ping(int t) { 6 q.push(t); 7 while (t - 3000 > q.front()) 8 q.pop(); 9 return q.size(); 10 } 11 };