Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
[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