Threshold Alerts
A compliance system monitors incoming and outbound calls. It sends an alert whenever the average
number of calls over a trailing number of minutes exceeds a threshold. If the number of trailing
minutes to consider, precedingMinutes = 5, at time T, take the average the call
volumes for times T-5(T-1), T-5(2)...T-5(5).
No alerts are sent until at least T = 3 because there are not enough values to consider. When T = 3, the average calls = (2 + 2 + 2)/3 = 2. Additionally, average calls from T = 3 to T = 8 are 2, 2, 3, 4, 5, and 6. A total of two alerts are sent during the last two periods. Given the data as described, determine the number of alerts sent by the end of the timeframe.
Complete the function numberOfAlerts in the editor.
numberOfAlerts has the following parameters:
- 1.
int precedingMinutes: the trailing number of minutes to consider - 2.
int alertThreshold: the maximum number of calls allowed before triggering an alert - 3.
int numCalls[n]:numCalls[i]represents the number of calls made during the ith minute
Returns
int: the number of alerts sent over the timeframe
٩(ˊᗜˋ*)و ♡ Credit to Oso𓂃 𓈒𓏸
1Example 1
2Example 2
Constraints
Limits and guarantees your solution can rely on.
1 ≤ precedingMinutes ≤ n1 ≤ alertThreshold ≤ 1051 <= n <= 1050 <= numCalls[i] <= 105