Maximum Requests in Window
Updated
Problem statement
Given a series of request timestamps, find the maximum number of requests that occur within any continuous time window of a specified length.
The function receives:
timestamp: request timestamps in minuteswindowSize: duration of the time window in minutes
Return the maximum number of requests observed in any window of length windowSize minutes.
Function
maxRequestInWindow(timestamp: int[], windowSize: int) → intExamples
Example 1
timestamp = [1,3,7,5]windowSize = 4return = 2Windows such as [1,4], [3,6], and [5,8] each contain two requests. The maximum is 2.
Example 2
timestamp = [2,2,3]windowSize = 1return = 2The window [2,2] includes both requests at time 2.
Constraints
1 <= timestamp.length <= 2 * 10^51 <= timestamp[i] <= 10^91 <= windowSize <= 10^9
More Salesforce Online Assessment questions
- Count Subarrays With Product Equal to KOA · Seen Nov 2026
- Minimum No-Repeat Segments After One Character RemovalOA · Seen Nov 2026
- Get Message StatusOA · Seen Nov 2026
- Minimum Unique-Character Segments After DeletionOA · Seen Sep 2026
- Run-Length String CompressionOA · Seen Sep 2026
- Final Pod Counts After LogsOA · Seen Aug 2026
- Minimum Removals to Balance ArrayOA · Seen Aug 2026
- Is This Date a Weekend?OA · Seen Aug 2026
- Maximum Barbell WeightOA · Seen Jul 2026
- Minimum Operations to ZeroOA · Seen Jul 2026
Similar questions at other companies
- Count Servers With No Requests in a Time WindowIBM · OAIBM interview questions
- Get Minimum BoxesAmazon · OA
- Earliest Hour with Frequent Badge AccessIntuit · OAIntuit interview questions
- Sliding Window MedianAuxoAI · OA
- Minimum Parking Roof LengthAmerican Express · OAAmerican Express interview questions
- Choose One from Each Set to Minimize the RangeInMobi · OAInMobi interview questions
- Integer Compression OffsetHeadlands Technologies · PHONE SCREENHeadlands Technologies interview questions
- Sliding Window Average After Trimming Both EndsGoogle · ONSITE INTERVIEWGoogle interview questions
- Maximize Element FrequencyGoldman Sachs · ONSITE INTERVIEWGoldman Sachs interview questions
- Tagged Metric Window SumsDatadog · PHONE SCREEN · ONSITE INTERVIEWDatadog interview questions