FastPrepMaximum Requests in a Time Window
Problems/Maximum Requests in a Time Window

Maximum Requests in a Time Window

IBM logoIBM● EasyFULLTIMENEW GRADOA

Updated Sep 2026

QuestionFunctionExamplesConstraints

Problem statement

Given an array of timestamps and a window size, find the maximum number of requests made within any time window defined as the closed interval [x, x + window - 1] for some integer x.

The function maximumRequests will take two inputs:

  • int window: the size of the time window
  • int timestamps[n]: array of request timestamps

The function should return an integer denoting the maximum number of requests made within any given window size.

Function

maximumRequests(window: int, timestamps: int[]) → int

Examples

Example 1

window = 5timestamps = [1, 2, 3, 8, 10]return = 3

The window [0, 4] contains 3 requests at timestamps 1, 2, and 3, which is the maximum among all windows of size 5. Hence, the answer is 3.

Constraints

  • 1 <= window <= 10^9
  • 1 <= n <= 2 * 10^5
  • 0 <= timestamps[i] <= 10^9
  • It is guaranteed that timestamps are sorted in non-decreasing order.

More IBM Online Assessment questions

  • Missing IntervalsOA · Seen Nov 2026
  • Count Peaks and ValleysOA · Seen Nov 2026
  • Last Object Exit TimeOA · Seen Nov 2026
  • Count Strictly Increasing Contiguous WindowsOA · Seen Nov 2026
  • Total Each Letter's Count in an Encoded StringOA · Seen Nov 2026
  • Count Servers With No Requests in a Time WindowOA · Seen Nov 2026
  • Maximum Easy Tasks After RearrangingOA · Seen Nov 2026
  • Tree Pythagorean TriplesOA · Seen Oct 2026
  • Minimum Power-of-Two Removal OperationsOA · Seen Oct 2026
  • Maximum Compatible Time WindowsOA · Seen Oct 2026

Similar questions at other companies

  • Maximum Events in a 60-Second WindowMarshall Wace · OAMarshall Wace interview questions
  • Count Subarrays With Product Equal to KSalesforce · OASalesforce interview questions
  • Count Belt Sections With K Fruit Pairs (Forward Deployed Engineer)Boston Consulting Group · OABoston Consulting Group interview questions
  • Fastest Average Speed over a Rolling KilometerOptiver · OAOptiver interview questions
  • Maximum Consecutive Sum Within a ThresholdIndeed · OAIndeed interview questions
  • Compact Conversation History by Token BudgetSierra · PHONE SCREENSierra interview questions
  • Subarray Product Less Than KApple · PHONE SCREENApple interview questions
  • Shortest Window with Required CountsOracle · ONSITE INTERVIEWOracle interview questions
  • Subarray Product Less Than KAngel One · PHONE SCREEN
  • Subarray Product Less Than KThe D.E. Shaw Group · PHONE SCREENThe D.E. Shaw Group interview questions

IBM interview experiences

  • IBM Full-Time SWE OA Questions: 1 Experience
  • IBM Software Intern Résumé Rounds: 2 Experiences (Part 3 of 3)
  • IBM Intern Blitz Interviews: 23 Experiences (Part 2 of 3)
  • IBM Software Intern Interviews: 44 Experiences (Part 1 of 3)
  • IBM Software Intern Interview Questions: 15 Experiences
All IBM interview questionsSee IBM hiring insights
Saved
class Solution {
    public int maximumRequests(int window, int[] timestamps) {
      // write your code here
    }
}
Checking account…