Skip to content

Instantly share code, notes, and snippets.

@fpdjsns
Created November 9, 2018 14:00
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fpdjsns/40262372506889ff5cfdfc8e6e8826a5 to your computer and use it in GitHub Desktop.
Save fpdjsns/40262372506889ff5cfdfc8e6e8826a5 to your computer and use it in GitHub Desktop.
[leetcode] 933. Number of Recent Calls : https://leetcode.com/problems/number-of-recent-calls
class RecentCounter {
public:
queue<int> q = queue<int>();
RecentCounter() {
q = queue<int>();
}
int ping(int t) {
q.push(t);
while(!q.empty() && q.front() < t-3000) q.pop();
return q.size();
}
};
/**
* Your RecentCounter object will be instantiated and called as such:
* RecentCounter* obj = new RecentCounter();
* int param_1 = obj->ping(t);
*/
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment