We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent ef0fa16 commit 1ccce8aCopy full SHA for 1ccce8a
leetcode-scala/src/main/scala/LeetCode75/Queue/933. Number of Recent Calls.sc
@@ -0,0 +1,23 @@
1
+class RecentCounter() {
2
+
3
+ private val queue = scala.collection.mutable.Queue.empty[Int]
4
5
+ def ping(t: Int): Int = {
6
+ queue.addOne(t)
7
+ val d = t - 3000
8
+ queue.dequeueWhile(_ < d)
9
+ queue.size
10
+ }
11
+}
12
13
+/**
14
+ * Your RecentCounter object will be instantiated and called as such:
15
+ * val obj = new RecentCounter()
16
+ * val param_1 = obj.ping(t)
17
+ */
18
19
+val counter = new RecentCounter()
20
+counter.ping(1)
21
+counter.ping(100)
22
+counter.ping(3001)
23
+counter.ping(3002)
0 commit comments