Ezvor

3851. Maximum Requests Without Violating the Limit

MediumArray Preparing judge… LeetCode
ArrayHash TableGreedySliding WindowSorting

Hints

Hint 1
Use a sliding-window approach.
Hint 2
For each user, maintain a sorted list (array) of their request times.
Hint 3
For each user, slide a window over their times; if the count inside any inclusive interval of length window exceeds k, remove the most recent request(s) in that interval until the count <= k.