Saturday, April 22, 2017

Find the minimum number of train platforms needed in each direction

Given the arrival time, departure time and direction of trains, find the minimum number of platforms needed in each direction to accommodate all trains such that no train has to wait.
Arrival time Departure time Direction
11:00 11:15 Up
11:05 11:20 Up
11:00 11:10 Down
11:15 11:25 Down

Sample Output:
2 platforms are needed in Up direction.
1 platform is needed in Down direction.

2 comments: