Data Structures & AlgorithmsHardProduct-company placement

Lectures occupy half-open intervals [start, end): [5, 13), [8, 13), [8, 16), [13, 16), [13, 17), [13, 18), [13, 20), [17, 22). A lecture ending at t frees its room for one starting at t. What is the minimum number of rooms needed?

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

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