Logger Rate Limiter

Design a logger that prints a message only if it has not been printed in the last 10 seconds. Pattern focus: Queue Simulation. A queue of active messages or timestamps helps enforce the time-based rule efficiently.

Input Format

messages = array of message strings, timestamps = corresponding times

Output Format

booleans indicating whether each message should be printed

Constraints

  • 1 <= input size <= 10^5
  • -10^9 <= numeric values <= 10^9
  • messages, timestamps must satisfy the format described in inputFormat.

Examples

Example 1:

Input:

messages = ["foo","bar","foo","bar","foo"]
timestamps = [1,2,3,8,11]

Output:

[true,true,false,false,false]

Explanation:

Repeated messages within 10 seconds are suppressed.

Example 2:

Input:

messages = ["a","a","a"]
timestamps = [1,11,21]

Output:

[true,true,true]

Explanation:

Each repeat occurs after 10 seconds, so all are printed.

Loading...
Logger Rate Limiter - Queue Deque DSA Problem