Threshold Alerts
Learn this problemProblem statement
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.
Function
numberOfAlerts(precedingMinutes: int, alertThreshold: int, numCalls: int[]) → int
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𓂃𓇼 ⋆.˚ 𓆉 𓆝 𓆡⋆.˚ 𓇼 𓈒𓏸
Examples
Example 1
precedingMinutes = 3alertThreshold = 10numCalls = [0, 11, 10, 10, 7]return = 1Example 2
precedingMinutes = 3alertThreshold = 5numCalls = [0, 11, 10, 10, 7]return = 3Constraints
1 ≤ precedingMinutes ≤ n1 ≤ alertThreshold ≤ 1051 <= n <= 1050 <= numCalls[i] <= 105
More Goldman Sachs problems
- Validate Binary Search TreeONSITE INTERVIEW · Seen Jul 2026
- Data ReorganizationSeen Jul 2026
- Inherited Role PermissionsONSITE INTERVIEW · Seen Jul 2026
- Root of the Largest TreePHONE SCREEN · Seen Jul 2026
- Alternating Parity PermutationsOA · Seen Jul 2026
- Cheapest Flights Within K StopsONSITE INTERVIEW · Seen Jun 2026
- Word LadderPHONE SCREEN · Seen Jun 2026
- Log Buffer AnalyzerOA · Seen May 2026