Challenge: Minimum Number of Platforms Required for Train Station

Given the arrival and departure times of trains, calculate the number of platforms required for a train station.

Problem statement

Implement a function that returns the minimum number of platforms that are required for the trains so that none of them wait.

Input

The input is two arrays that represent the arrival and departure times of trains that stop.

Output

The output is the minimum number of platforms required.

Sample input

Arrival Time Departure Time
9:00 9:10
9:40 12:00
9:50 11:20
11:00 11:30
15:00 19:00
18:00 20:00
 arrival[] = {900, 940, 950, 1100, 1500, 1800};
 departure[] = {910, 1200, 1120, 1130, 1900, 2000};

Sample output

Minimum platforms needed = 3

Level up your interview prep. Join Educative to access 70+ hands-on prep courses.