Problem · Hash Table

Logger Rate Limiter

Learn this problem
EasyAtlassian logoAtlassianFULLTIMEOA

Problem 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 100000 events.

More Atlassian problems

drafts saved locally
public boolean[] shouldPrintSequence(int[] timestamps, String[] messages) {
  // Write your code here.
}
timestamps[1,2,3,8,10,11]
messages["foo","bar","foo","bar","foo","foo"]
expected[true,true,false,false,false,true]
checking account