Data Structures19 sections · 729 units
Open in Course

Problem - Number of Recent Calls

Simple queue problem

Design a class that counts the number of recent requests within a certain time frame.

Implement a ping(t) method that adds a new request at time tt and returns the number of requests in the past 30003000 milliseconds (from t3000t - 3000 to tt).

You're solving a warm-up queue problem. You need to track recent requests and remove old ones.