 All Problems
Logger Rate Limiter
easy
design
hash table
google
facebook

Design a logger system that receives a stream of messages and their timestamps. Each unique message should only be printed at most every 10 seconds.

Implement the Logger class:

  • boolean shouldPrintMessage(int timestamp, String message) — returns true if the message should be printed.

Example:

shouldPrintMessage(1,"foo")→true, shouldPrintMessage(2,"bar")→true,
shouldPrintMessage(3,"foo")→false, shouldPrintMessage(8,"bar")→false,
shouldPrintMessage(10,"foo")→false, shouldPrintMessage(11,"foo")→true
Run to check your code against the sample cases, or submit to run every case