Delayed Streaming Duplicate Suppression
Problem statement
A logging service receives a stream of statuses in nondecreasing timestamp order. Each status contains an integer timestamp in seconds and a case-sensitive message.
A status is isolated when no other status with the exact same message has an absolute timestamp difference strictly less than 10 seconds. If two equal messages occur within that window, both occurrences are suppressed. This rule can suppress every status in a chain of nearby equal messages.
Examples
Example 1
timestamps = [1,5,12,23]messages = ["foo","foo","foo","foo"]return = ["[23s] foo"]The occurrences at 1 and 5 are within 4 seconds, while those at 5 and 12 are within 7 seconds, so the first three statuses are suppressed. The occurrence at 23 is 11 seconds after the preceding one and is shown.
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.