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

Closed intervals [1,4], [2,6], [4,7], [5,9], [8,10] are given. What is the largest number of intervals that share a single integer point?

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

Correct answer: C. 3

Sweep over the points: the answer is the peak count of intervals covering one point. Closed intervals include both endpoints, so the point 4 is covered by [1,4], [2,6] and [4,7].

More Coding Interview Problems questions

Exams that ask this topic