Number of Recent Calls LeetCode solution in JavaScript

1
var RecentCounter = function () {
2
this.arr = [];
3
};
4

5
RecentCounter.prototype.ping = function (t) {
6
this.arr.push(t);
7
while (t > this.arr[0] + 3000) {
8
this.arr.shift();
9
}
10
return this.arr.length;
11
};

0

WPM •0 •0

100%

ACC •0 •0

0s

TIME •0