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

Intervals [0,4], [3,7], [6,10], [2,6], [9,12], [1,3] are available. What is the minimum number of them needed to cover the whole segment [0, 10], meaning every point x with 0 <= x <= 10 lies in some chosen interval?

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

Correct answer: C. 3

Repeatedly extend the covered prefix: among intervals starting at or before the current reach, pick the one that ends furthest right. Choosing by shortest length or counting every interval that touches the segment gives different totals.

More Coding Interview Problems questions

Exams that ask this topic