Search⌘ K
AI Features

Solution: Logger Rate Limiter

Explore how to implement a logger rate limiter that filters out duplicate messages received within a specified time frame. Understand the use of hash maps to track message timestamps efficiently, enabling constant-time checks to accept or reject messages. Learn to balance time and space complexity while coding the solution, preparing you to handle similar challenges in coding interviews.

Statement

For the given stream of message requests and their timestamps as input, you must implement a logger rate limiter system that decides whether the current message request is displayed. The decision depends on whether the same message has already been displayed in the last SS seconds. If yes, then the decision is FALSE, as this message is considered a duplicate. Otherwise, the decision is TRUE.

Note: Several message requests, though received at different timestamps, may carry identical messages.

Constraint:

  • 11 \leq request.length 102\leq 10^{2}
...