Data Structures & AlgorithmsHardProduct Company SDE · Amazon OA

Problem: Video clips of the form [start, end] cover the interval [0, 10]. The clips are [0,2], [4,6], [8,10], [1,9], [2,5], [5,7]. What is the minimum number of clips needed to cover [0, 10] completely?

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

Correct answer: A. 3

Greedy coverage: from the current end, extend with the clip that starts before it and reaches farthest. Taking the first clip that starts at the current end can waste a clip.

More Coding Interview Problems questions

Exams that ask this topic