From 2bc4f9c171054cba4a695eb436305355a968c9ca Mon Sep 17 00:00:00 2001 From: ductnn Date: Sun, 17 Dec 2023 00:23:16 +0700 Subject: [PATCH] add sol --- .../numberOfRecentCalls.go | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 leetcode/leetcode75/Queue/933.NumberOfRecentCalls/numberOfRecentCalls.go diff --git a/leetcode/leetcode75/Queue/933.NumberOfRecentCalls/numberOfRecentCalls.go b/leetcode/leetcode75/Queue/933.NumberOfRecentCalls/numberOfRecentCalls.go new file mode 100644 index 0000000..6de8708 --- /dev/null +++ b/leetcode/leetcode75/Queue/933.NumberOfRecentCalls/numberOfRecentCalls.go @@ -0,0 +1,23 @@ +package main + +type RecentCounter struct { + q []int +} + +func Constructor() RecentCounter { + return RecentCounter{[]int{}} +} + +func (this *RecentCounter) Ping(t int) int { + this.q = append(this.q, t) + for this.q[0] < t-3000 { + this.q = this.q[1:] + } + return len(this.q) +} + +/** + * Your RecentCounter object will be instantiated and called as such: + * obj := Constructor(); + * param_1 := obj.Ping(t); + */