FastPrepMaximum Compatible Time Windows
Problems/Maximum Compatible Time Windows

Maximum Compatible Time Windows

IBM logoIBM● MediumFULLTIMEOA

Updated Nov 2026

QuestionFunctionExamplesConstraints

Problem statement

Source note: Reported in an IBM online assessment. The report gives half-open window rules, the goal of the selection, the shape of the function, examples, and limits on the numbers. One example input line was hidden by a watermark. Our version is about 96% the same as the reported question.

You are given two integer arrays, startTime and endTime, each of length n. Time window i begins at startTime[i], inclusive, and ends at endTime[i], exclusive.

Select as many pairwise non-overlapping time windows as possible and return the maximum number selected. Because each window is half-open, one selected window may end exactly when another selected window begins.

Function

selectMostCompatibleWindows(startTime: int[], endTime: int[]) → int

Examples

Example 1

startTime = [1,1,2]endTime = [3,2,4]return = 2

You may select window 0 by itself, or select windows 1 and 2. The latter two are compatible because window 1 ends exactly when window 2 begins.

Example 2

startTime = [1,1,2,3]endTime = [2,3,3,4]return = 3

Select windows 0, 2, and 3: [1,2), [2,3), and [3,4).

Example 3

startTime = [5,5,5]endTime = [8,7,6]return = 1

All three windows overlap, so at most one can be selected.

Constraints

  • 1 <= n <= 10^5.
  • 1 <= startTime[i], endTime[i] <= 10^9.
  • startTime[i] < endTime[i] for every time window.

More IBM Online Assessment questions

  • Missing IntervalsOA · Seen Nov 2026
  • Last Object Exit TimeOA · Seen Nov 2026
  • Count Peaks and ValleysOA · 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
  • Query Type Frequency WindowOA · Seen Oct 2026

Similar questions at other companies

  • Minimum Markers to Clear Line SegmentsHSBC · OAHSBC interview questions
  • Minimum Machines for TasksExpedia · OAExpedia interview questions
  • Most Disjoint Intervals From Starts and DurationsDocuSign · OADocuSign interview questions
  • University Career FairRoblox · OARoblox interview questions
  • Minimum Removals for Non-Overlapping IntervalsByteDance · PHONE SCREEN · ONSITE INTERVIEWByteDance interview questions
  • Maximum Number of Events That Can Be AttendedSnowflake · PHONE SCREENSnowflake interview questions
  • Minimum Workers with Job AssignmentsLyft · ONSITE INTERVIEWLyft interview questions
  • Minimum Appointment Cancellations with a Required BreakMaven Clinic · PHONE SCREENMaven Clinic interview questions
  • Minimum Removals for Non-Overlapping IntervalsBloomberg LP · ONSITE INTERVIEWBloomberg LP interview questions
  • Minimum Meeting RoomsSentry · PHONE SCREENSentry 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 selectMostCompatibleWindows(int[] startTime, int[] endTime) {
      // write your code here
    }
}
Checking account…