FastPrepMaximum Requests in Window
Problems/Maximum Requests in Window

Maximum Requests in Window

Salesforce logoSalesforce● MediumFULLTIMEOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

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 minutes
  • windowSize: 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) → int

Examples

Example 1

timestamp = [1,3,7,5]windowSize = 4return = 2

Windows 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 = 2

The window [2,2] includes both requests at time 2.

Constraints

  • 1 <= timestamp.length <= 2 * 10^5
  • 1 <= timestamp[i] <= 10^9
  • 1 <= 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

Salesforce interview experiences

  • Salesforce Infrastructure SWE OA and Onsite: 1 Experience
  • Salesforce Experienced Backend SWE First Round: 1 Experience
All Salesforce interview questionsSee Salesforce hiring insights
Saved
class Solution {
    public int maxRequestInWindow(int[] timestamp, int windowSize) {
      // write your code here
    }
}
Checking account…