Problem · Array
Maximum Requests in Window
Learn this problemProblem 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 problems
- Diameter of an Acyclic Undirected GraphONSITE INTERVIEW · Seen Jul 2026
- Optimal Account BalancingPHONE SCREEN · Seen Jul 2026
- Longest Increasing SubsequencePHONE SCREEN · Seen Jul 2026
- Maximal SquarePHONE SCREEN · Seen Jul 2026
- Maximum Barbell WeightOA · Seen Jul 2026
- Minimum No-Repeat Segments After One Character RemovalOA · Seen Jul 2026
- Minimum Operations to ZeroOA · Seen Jul 2026
- Minimize Total Input Cost (for LTMS)OA · Seen Jun 2026