Solution: Logger Rate Limiter
Understand how to implement a logger rate limiter that decides to display messages based on recent duplicates within a given time frame. Learn to use hash maps to track message timestamps efficiently, achieving constant time complexity for checks and updates. This lesson guides you through both naive queue-based and optimized hash map approaches to handle message stream inputs.
We'll cover the following...
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 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:
-
request.length