Data Structures & AlgorithmsHardProduct company OA · Amazon/Microsoft-style OA

Half-open intervals [1,6), [2,4), [3,8), [5,7), [6,9), [7,10) are given. What is the maximum number of intervals that contain a common time point?

  1. A. 3
  2. B. 4
  3. C. 5
  4. D. 6

Correct answer: A. 3

The answer is the peak overlap, found by sweeping the start and end events and keeping a running count; with half-open intervals, an interval ending at t does not cover t. Counting the intervals that start before the peak is not the same quantity.

More Coding Interview Problems questions

Exams that ask this topic