WhiZTiM

Number of Recent Calls

May 25th, 2019
153
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.24 KB | None | 0 0
  1. class RecentCounter {
  2.     std::deque<int> p;
  3. public:
  4.     RecentCounter() {
  5.        
  6.     }
  7.    
  8.     int ping(int t) {
  9.         p.push_back(t);
  10.         while(p.back() - p.front() > 3000) p.pop_front();
  11.         return p.size();
  12.     }
  13. };
Add Comment
Please, Sign In to add comment