From a173bca0dd51a2ff19cf1bbfc774f5f19fe99b91 Mon Sep 17 00:00:00 2001 From: Vaibhav Agarwal <53373756+vacodr@users.noreply.github.com> Date: Fri, 2 Oct 2020 08:34:55 +0530 Subject: [PATCH] Create Adding a new problem in the list https://leetcode.com/problems/number-of-recent-calls/ --- Adding a new problem in the list | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 Adding a new problem in the list diff --git a/Adding a new problem in the list b/Adding a new problem in the list new file mode 100644 index 00000000..613f8325 --- /dev/null +++ b/Adding a new problem in the list @@ -0,0 +1,25 @@ +/* +Submitted by: Vaibhav Agarwal https://github.com/vacodr +Problem: https://leetcode.com/problems/number-of-recent-calls/ +Difficulty: Easy +*/ + +class RecentCounter { + Queue time = new LinkedList(); + public RecentCounter() { + + } + + public int ping(int t) { + time.add(t); + + while (time.peek() < t - 3000) { + + //System.out.printf(time.peek()+" "); + + time.poll(); + } + return time.size(); + } + +}