Data Structures & AlgorithmsHardProduct-company placement

Lectures occupy half-open intervals [start, end): [2, 7), [6, 11), [8, 14), [9, 14), [10, 16), [13, 16), [13, 20), [14, 20). A lecture ending at t frees its room for one starting at t. What is the minimum number of rooms needed?

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

Correct answer: C. 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 6.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic