AlgoMaster Logo
AlgoMasterDeduplicate Alert Notificationsmedium

Deduplicate Alert Notifications

medium

An alert manager should not send a new page for every evaluation of the same active alert. It groups equivalent alerts by fingerprint, suppresses repeats for a configured interval, and forgets the active incident after resolution.

Design an AlertNotificationManager class:

  • AlertNotificationManager() creates a stateless manager.
  • boolean[] notificationStates(String[] fingerprints, int[] states, int[] timestamps, int repeatInterval) returns whether each event sends a notification.

Arrays are aligned and processed chronologically. states[i] == 1 means firing; states[i] == 0 means resolved.

  • A firing event for an inactive fingerprint notifies immediately and activates it.
  • An active fingerprint notifies again only when at least repeatInterval time has passed since its last notification.
  • A repeated notification resets that fingerprint's repeat timer.
  • Resolution never notifies and clears the fingerprint. Its next firing event is new.
Example 1:

Input:

Output:

Explanation: The active alert repeats at timestamp 10. Resolution at 12 clears it, so firing at 13 produces a fresh notification.

Example 2:

Input:

Output:

Explanation: Each fingerprint owns its timer. Disk's second event occurs 11 units after its notification; CPU's occurs only 5 units later.

Constraints

  • 1 <= fingerprints.length == states.length == timestamps.length <= 10^5
  • Fingerprints are non-empty lowercase strings.
  • states[i] is 0 or 1.
  • 0 <= timestamps[i] <= 10^9, and timestamps are nondecreasing.
  • 0 <= repeatInterval <= 10^9
  • Return one decision per event in input order.
  • At most 100 calls are made to notificationStates.
Hints

Loading...
CallReturns
new AlertNotificationManager()null
notificationStates(["cpu","cpu","cpu","cpu","cpu"], [1,1,1,0,1], [0,5,10,12,13], 10)[true,false,true,false,true]

CPU notifies when it first fires, repeats at 10, resolves silently, and notifies immediately when it fires again.

Run checks these cases. Submit also runs a larger hidden set.