FastPrepOut-of-Order Logger Rate Limiter
Problem · Hash Table

Out-of-Order Logger Rate Limiter

HardGoogle logoGoogleFULLTIMEONSITE INTERVIEW
See Google hiring insights

Problem statement

A logger receives messages whose integer event timestamps may arrive out of order. Process the paired arrays timestamps and messages in input order.

For an event with timestamp t and message m, print it exactly when no earlier accepted event for m has an event timestamp in the inclusive interval [t - 9, t]. An earlier-processed event whose timestamp is greater than t does not block this event. A rejected event does not update the accepted history, and decisions are never revised retroactively.

The problem statement continues
Pro

Examples

Example 1

timestamps = [10,15,5,20]messages = ["foo","foo","foo","foo"]return = [true,false,true,true]

The event at 10 prints, so the one at 15 is suppressed. Timestamp 5 then prints because the already processed timestamp 10 is later than its query interval. Timestamp 20 is ten seconds after the accepted event at 10, so it also prints.

FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week
CodePython 3
Run and Submit unlock with Pro
FastPrep Pro
Reported in 1 Google interview this week

Unlock this recently reported problem

FastPrep Pro gives you full access to interview problems reported within the last week.

  • Full problem statement and constraints
  • 1 more worked example, explained
  • Guided hints and editorial
  • Run your code on real test cases
$8.25/month

$99 billed yearly — or $19 month-to-month. Cancel anytime.

Free plan — 2 of 2 free unlocks used this week