Threshold Alerts
Updated
Problem 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
Examples
Example 1
precedingMinutes = 3alertThreshold = 10numCalls = [0, 11, 10, 10, 7]return = 1An alert is sent at the end of three minutes since the average number of calls during the interval (11, 10, and 10) exceeds 10.
Example 2
precedingMinutes = 3alertThreshold = 5numCalls = [0, 11, 10, 10, 7]return = 3An alert is sent at the ends of minutes 2, 3, and 4 since the average number of calls in the previous three minutes (0,11,10), (11,10,10), and (10, 10, 7) exceed 5.
Constraints
1 ≤ precedingMinutes ≤ n1 ≤ alertThreshold ≤ 1051 <= n <= 1050 <= numCalls[i] <= 105
More Goldman Sachs interview questions
- House Robber IIIPHONE SCREEN · Seen Nov 2026
- Knight Probability in ChessboardONSITE INTERVIEW · Seen Nov 2026
- Trapping Rain WaterPHONE SCREEN · Seen Nov 2026
- Maximum Ones After K OperationsOA · Seen Nov 2026
- Palindrome CounterOA · Seen Oct 2026
- Longest Palindromic SubsequenceOA · Seen Oct 2026
- Best Average Student ScorePHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Check a Complete Binary TreePHONE SCREEN · Seen Oct 2026
- Meeting RoomsPHONE SCREEN · ONSITE INTERVIEW · Seen Oct 2026
- Minimum Meeting Rooms Without a Sweep LineONSITE INTERVIEW · Seen Oct 2026
Similar questions at other companies
- Reduce Memory UsageAmazon · OA
- Profit AnalysisVirtu Financial · OA
- Minimum Size Subarray SumMicrosoft · OA
- Count Hotspot Playback WindowsGoogle · ONSITE INTERVIEW
- Maximum Value for Two Delivery RobotsNuro · PHONE SCREEN
- Subarray with a Given SumExpedia · ONSITE INTERVIEW
- Longest Run of Ones After Flipping k ZerosC3.ai · PHONE SCREEN
- Count Strictly Increasing Contiguous WindowsIBM · OA
- Minimum Positive Starting ValueBooking.com · OA
- Array Interval SumsHeadlands Technologies · OA