Data Structures & AlgorithmsModerateGATE CS · TCS NQT

Trains arrive at times [900, 940, 950, 1100] and depart at times [910, 1200, 1120, 1130]. What is the minimum number of platforms needed so that no train waits?

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

Correct answer: B. 3

Sort all arrival and departure events; process departures before arrivals at equal times is not needed here. Count the trains present at each moment and take the maximum.

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

Exams that ask this topic