Data Structures & AlgorithmsModerateICPC regional · Amazon SDE OA

Trains arrive at times 2, 4, 4, 6, 8 and depart at 3, 5, 7, 6, 9 (a departure at the same time as an arrival frees its platform first). What is the minimum number of platforms?

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

Correct answer: C. 2

Sweeping the sorted events, the number of trains present never exceeds two: two trains arrive at time 4, and each departure at 5 and 6 frees a platform.

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

Exams that ask this topic