class RecentCounter {
public:
RecentCounter() {
}
int ping(int t) {
}
};
/**
* Your RecentCounter object will be instantiated and called as such:
* RecentCounter* obj = new RecentCounter();
* int param_1 = obj->ping(t);
*/
type RecentCounter struct {
req []int
counter int
}
func Constructor() RecentCounter {
return RecentCounter{
req: []int{},
counter: 0,
}
}
func (this *RecentCounter) Ping(t int) int {
this.req = append(this.req, t)
begin, end := t-3000, t
this.counter++
ans := 0
for _, n := range this.req {
if n >= begin && n <= end {
ans++
}
}
return ans
}
/**
* Your RecentCounter object will be instantiated and called as such:
* obj := Constructor();
* param_1 := obj.Ping(t);
*/