A broken service floods the monitoring screen with the same alert. Show an alert, then hide repeats of that exact text for 10 seconds.
Build AlertMuter() with should_show(t: int, message: str) -> bool: return True (show it) if message was never shown, or was last shown at s with s + 10 <= t; otherwise False. Hidden alerts don't restart the 10 seconds. t never decreases, and alerts can share a second.
m = AlertMuter()
m.should_show(1, "disk full") # True
m.should_show(2, "cpu hot") # True
m.should_show(3, "disk full") # False (shown at 1)
m.should_show(8, "cpu hot") # False
m.should_show(11, "disk full") # True (1 + 10 <= 11)
m.should_show(11, "disk full") # False (just shown at 11)
m.should_show(12, "cpu hot") # True
⭐ Bonus: scanning the history still passes; a speed test with 300,000 calls earns a star at O(1) average per call.
Show hint
per message you need one number: when it was last shown.