FastPrepLogger Rate Limiter
Problems/Logger Rate Limiter

Logger Rate Limiter

Amazon Web Services logoAmazon Web Services● EasyNEW GRADONSITE INTERVIEW

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an Amazon Web Services new grad onsite interview. The report names the well-known logger rate limiter task. It does not give the function signature, the rule at the edge of the time window, or the limits. Our version is about 95% the same as the reported question.

A logger receives a sequence of messages with integer timestamps. It may print the same message at most once in any 10-second interval.

Process the events in the given order. A message at timestamp t is printed when it has never been printed before, or when its most recent printed occurrence was at or before t - 10. A suppressed event does not change that message's most recent printed timestamp.

Return one boolean per event: true when the event is printed and false when it is suppressed. Different message strings are limited independently.

Function

shouldPrintMessages(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]

The first foo and bar events print. Their later occurrences before timestamps 11 and 12, respectively, are suppressed. At timestamp 11, exactly 10 seconds have passed since foo last printed, so it prints again.

Example 2

timestamps = [5,5,14,15]messages = ["x","x","x","x"]return = [true,false,false,true]

The first event prints. The event at timestamp 14 is still only 9 seconds after that printed event. The event at timestamp 15 reaches the boundary and prints.

Example 3

timestamps = [0,1,2,9,10]messages = ["a","b","c","b","b"]return = [true,true,true,false,false]

The three distinct messages print independently. Message b last printed at timestamp 1, so its events at timestamps 9 and 10 are both too early.

Constraints

  • 1 ≤ timestamps.length = messages.length ≤ 200000.
  • 0 ≤ timestamps[i] ≤ 10^9.
  • timestamps is nondecreasing.
  • Each message is a non-empty printable ASCII string of length at most 100.

More Amazon Web Services Onsite Interview questions

  • Group AnagramsONSITE INTERVIEW · Seen Nov 2026
  • Longest Substring with At Most K Distinct CharactersONSITE INTERVIEW · Seen Nov 2026
  • Fixed-K Kth Largest StreamONSITE INTERVIEW · Seen Aug 2026
  • Recent Hit CounterONSITE INTERVIEW · Seen Aug 2026
  • Spreadsheet Formula DependenciesONSITE INTERVIEW · Seen Aug 2026

Similar questions at other companies

  • Machine Message RouterOpenAI · PHONE SCREENOpenAI interview questions
  • Count a User's Actions in an Event LogMicrosoft · ONSITE INTERVIEWMicrosoft interview questions
  • Map and Accumulate Learning QueriesPalantir · ONSITE INTERVIEWPalantir interview questions
  • Filter Pins by Excluded IDsPinterest · ONSITE INTERVIEWPinterest interview questions
  • Longest Dictionary Word from Nine LettersGoogle · ONSITE INTERVIEWGoogle interview questions
  • Loyal Customers by Two-Day Product VarietyAmazon · ONSITE INTERVIEW
  • Design an Ordered StreamBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
  • Card Transaction StreamCapital One · ONSITE INTERVIEWCapital One interview questions
  • Find Nodes with Invalid Parent LevelsZip · ONSITE INTERVIEWZip interview questions
  • Most Voted CandidateExpedia · ONSITE INTERVIEWExpedia interview questions

Amazon Web Services interview experiences

  • AWS New Grad SDE Interview Loops
All Amazon Web Services interview questionsSee Amazon Web Services hiring insights
Saved
class Solution {
    public boolean[] shouldPrintMessages(int[] timestamps, String[] messages) {
        // Write your code here.
    }
}
Checking account…