Leetcode 359. Logger Rate Limiter
Mar 12, 2021
easy — apple interview question
Design a logger system that receives a stream of messages along with their timestamps. Each unique message should only be printed at most every 10 seconds (i.e. a message printed at timestamp t
will prevent other identical messages from being printed until timestamp t + 10
).
All messages will come in chronological order. Several messages may arrive at the same timestamp.
Implement the Logger
class:
Logger()
Initializes thelogger
object.bool shouldPrintMessage(int timestamp, string message)
Returnstrue
if themessage
should be printed in the giventimestamp
, otherwise returnsfalse
.