Data Structures & AlgorithmsHardCodeforces Div2 C · GATE CS

A railway station receives trains at times 900, 940, 950, 1100, 1500, 1800 and each train leaves at 910, 1200, 1120, 1130, 1900, 2000 respectively. What is the minimum number of platforms needed so that no train waits?

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

Correct answer: D. 3

Sort arrivals and departures separately and sweep, a departure at the same time as an arrival frees its platform first. The maximum simultaneous count is 3, reached at time 1100.

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

Exams that ask this topic