Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

Meetings are half-open intervals [s, e) listed as (1,4), (2,5), (3,6), (7,9), (8,10), (5,7). A meeting ending at time t and another starting at t can share a room. What is the minimum number of rooms needed?

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

Correct answer: D. 3

The answer is the maximum number of intervals overlapping at any instant, found by sorting start and end events and sweeping. Processing a start before an end at the same time overcounts the rooms.

More Arrays, Strings, Linked Lists, Stacks, Queues and Hashing questions

Exams that ask this topic