Problem · Hash Table
Logger Rate Limiter
Learn this problemProblem statement
For each chronological (timestamp, message) pair, return whether the message should print. The same message may print again only when at least 10 seconds have passed since its most recent successful print. A rejected event does not reset the timer.
Function
shouldPrintSequence(timestamps: int[], messages: String[]) → boolean[]Examples
Example 1
timestamps = [1,2,3,8,10,11]messages = ["foo","bar","foo","bar","foo","foo"]return = [true,true,false,false,false,true]Foo becomes eligible again at time 11, ten seconds after its successful print at time 1.
Constraints
- The arrays have equal non-zero length.
- Timestamps are non-decreasing.
- There are at most
100000events.