Data Structures & AlgorithmsHardProduct-company placement

Lectures occupy half-open intervals [start, end): [3, 10), [6, 10), [7, 12), [9, 11), [10, 15), [10, 17), [10, 18), [20, 25). A lecture ending at t frees its room for one starting at t. What is the minimum number of rooms needed?

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

Correct answer: A. 5

Sweep the times, processing an end before a start at the same instant; the peak number of overlapping lectures is 5. Treating touching intervals as overlapping gives 7.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic