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);
*/