Skip to main content
All Questions

Show a streamed message only if it does not repeat within 10 seconds.

Unlock detailed company stats for this questionUpgrade

Variant of LC 359 Logger Rate Limiter. You process a stream of messages arriving sequentially by timestamp. Given a 10-second window, a message should be shown if and only if it does not appear twice within any 10-second window; if a message appears within 10 seconds of another instance of the exact same message, both instances are suppressed. Input: struct Status { var timestamp: Int; var message: String } and func getNextStatus() -> Status. Implement showMessage(_ status: Status) to process the stream dynamically. Constraints: the stream is live, so you do not have the full input upfront; a future duplicate can invalidate a message that just arrived, so you must buffer or delay output until no duplicate can appear in its 10-second window. Discussion: memory footprint for an infinite stream, and whether a sliding-window deque or doubly-linked list can replace a full tracking map.

Community answers

No answers contributed by the community yet.

Related courses

Course

Software Engineering Interview Prep

Land your dream software engineering role at Google, Amazon, Microsoft, Meta, Apple, and other top companies. Learn from mock interviews, frameworks, and advice from senior candidates—practice data structures, algorithms, system design, people management, behavioral interviews, and more.

Course

System Design Interviews

Learn how to answer the latest system design questions across product, infrastructure, and AI domains. Features in-depth video examples, written breakdowns, and helpful reference patterns. Watch senior engineers and managers answer these questions in mock interview videos.