HTMLify
LeetCode - Number of Recent Calls - Go
Views: 313 | Author: abh
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | type RecentCounter struct { pings []int } func Constructor() RecentCounter { var rc RecentCounter return rc } func (this *RecentCounter) Ping(t int) int { this.pings = append(this.pings, t) var pings int for _, p := range this.pings { if t - 3000 <= p && p <= t { pings++ } } return pings } /** * Your RecentCounter object will be instantiated and called as such: * obj := Constructor(); * param_1 := obj.Ping(t); */ |