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

Half-open intervals [1,5), [3,8), [6,10), [9,12) are given. How many integer points x are covered by at least two of these intervals?

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

Correct answer: C. 5

Sweep the events and track the count; points where the count reaches two form the answer. Treating intervals as closed adds the endpoint integers, which changes the total.

More Coding Interview Problems questions

Exams that ask this topic