From 05fc65409a8c16c130f96518b8d8868c01aa078a Mon Sep 17 00:00:00 2001 From: Rachit Jain <32428330+rachitiitr@users.noreply.github.com> Date: Thu, 1 Oct 2020 22:46:07 +0530 Subject: [PATCH] Create 933.number-of-recent-calls.cpp --- LeetCode/933.number-of-recent-calls.cpp | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 LeetCode/933.number-of-recent-calls.cpp diff --git a/LeetCode/933.number-of-recent-calls.cpp b/LeetCode/933.number-of-recent-calls.cpp new file mode 100644 index 0000000..20c3f03 --- /dev/null +++ b/LeetCode/933.number-of-recent-calls.cpp @@ -0,0 +1,21 @@ +#include + +class RecentCounter { + deque req; +public: + RecentCounter() { + req = {}; + } + + int ping(int t) { + req.push_back(t); + while(req.front() < t-3000) req.pop_front(); + return req.size(); + } +}; + +/** + * Your RecentCounter object will be instantiated and called as such: + * RecentCounter* obj = new RecentCounter(); + * int param_1 = obj->ping(t); + */