Logger Rate Limiter
Updated
Problem statement
Given a stream of logs in arrival order as timestamps and messages, return a boolean array whose i-th value is true when the i-th log is sent on and false when it is held back.
Log i arrived at second timestamps[i] with the text messages[i]. A log is sent unless the same message was already sent in the last 10 seconds: the log at time t is held back when an earlier log with the same message was sent at a time greater than t - 10. Only logs that were sent count. A held-back log does not restart the 10 seconds, and a message sent again exactly 10 seconds after its last send goes out.
Examples
Example 1
timestamps = [10,11,13,14,21,35]messages = ["ABCD","XYZ","ABCD","XYZ","ABCD","XYZ"]return = [true,true,false,false,true,true]ABCD is sent at 10 and XYZ at 11. At 13 and 14 the same messages were sent less than 10 seconds ago, so both are held back. At 21, ABCD was last sent at 10, 11 seconds earlier, so it is sent. At 35, XYZ was last sent at 11, 24 seconds earlier, so it is sent.
Unlock this recently reported problem
FastPrep Pro gives you full access to interview problems reported within the last week.
- Full problem statement and constraints
- 2 more worked examples, explained
- Guided hints and editorial
- Run your code on real test cases
$99 billed yearly — or $19 month-to-month. Cancel anytime.
More Google Phone Screen questions
- Count Winning Dice Face PairsPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Logger Rate Limiter with Every-Arrival HistoryPHONE SCREEN · Seen Nov 2026
- Minimum Cars for Rental RequestsOA · PHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Route Pattern MatcherPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Periodic-Color Binary Forest RootsPHONE SCREEN · Seen Nov 2026
- Evaluate a Nested Math ExpressionPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Best Stock Trade with Buy and Sell DaysPHONE SCREEN · Seen Nov 2026
- Word Chain Jumps in a GridPHONE SCREEN · Seen Nov 2026
- Dice-Walk Winning ProbabilityPHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
- Lowest Common Ancestor in an N-ary TreePHONE SCREEN · ONSITE INTERVIEW · Seen Nov 2026
Similar questions at other companies
- Design an Ordered StreamBloomberg LP · OA · PHONE SCREEN · ONSITE INTERVIEWBloomberg LP interview questions
- Insert Delete GetRandom O(1)Charta Health · PHONE SCREENCharta Health interview questions
- Portfolio Tickers with Constant-Time Random PickCitadel · PHONE SCREENCitadel interview questions
- Randomized String MultisetLinkedIn · PHONE SCREENLinkedIn interview questions
- Build a Pivot Table with TotalsSigma Computing · PHONE SCREEN
- Process On-Call Routing OperationsOpenAI · PHONE SCREENOpenAI interview questions
- Stateful Paginated Fetch NLyft · PHONE SCREENLyft interview questions
- Linear-Probing Key-Value StoreEase · PHONE SCREEN
- Escape Room LeaderboardPinterest · PHONE SCREEN · ONSITE INTERVIEWPinterest interview questions
- Role-Based Network Access ControlOkta · PHONE SCREENOkta interview questions