FreeCareerPath
Build the PrimitiveMedium

Suppress Duplicate Alerts

An alerting pipeline fires the same alert repeatedly while a condition persists. You need to suppress duplicates: an alert with a given key should only pass through if that key has not been seen in the last `window` seconds. Implement an `AlertSuppressor` class: - `AlertSuppressor(window)` — construct with a suppression window in seconds. - `should_emit(key, now)` — return `True` if this alert should fire, `False` if it is suppressed. `now` is a monotonically non-decreasing timestamp in seconds. The trap is memory: a naive dictionary keyed by alert key grows forever on a long-running process with high-cardinality keys. Keep the bookkeeping bounded.

What to expect: A timer starts when you begin. Edit the starter code, run it against the test suite as many times as you like, then finish when you're done. The reference solution and interviewer follow-up questions unlock only after you finish.

Log in to start this session

Timed sessions and your results for "Suppress Duplicate Alerts" are saved to your account — logging in takes a few seconds.

Suppress Duplicate Alerts — FreeCareerPath