Data Structures & AlgorithmsHardGATE CS · TCS NQT

Arrivals at times 1, 2, 3, 5 and departures at 2, 4, 5, 6 (each arrival pairs with a departure; a train leaving at time t frees its platform for one arriving at time t). What is the minimum number of platforms?

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

Correct answer: B. 2

Sweep events in time order with departures processed before arrivals at equal times. Processing arrivals first at ties over-counts platforms here.

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

Exams that ask this topic