1. var RecentCounter = function() {
    2. this.queue = []
    3. };
    4. /**
    5. * @param {number} t
    6. * @return {number}
    7. */
    8. RecentCounter.prototype.ping = function(t) {
    9. this.queue.push(t)
    10. while(this.queue[0] < t - 3000) {
    11. this.queue.shift()
    12. }
    13. return this.queue.length
    14. };
    15. /**
    16. * Your RecentCounter object will be instantiated and called as such:
    17. * var obj = new RecentCounter()
    18. * var param_1 = obj.ping(t)
    19. */