Minimum Platforms Required

Given arrays of train arrival times `arrivals` and departure times `departures` (both in 24-hour format, e.g., 900 for 9:00 AM), compute the minimum number of platforms required so that no train waits. **Pattern focus:** Separate Start and End Sweeps. Similar to meeting rooms, count concurrent trains.

Examples

Example 1:

Input:

arrivals = [900,940,950,1100,1500,1800]
departures = [910,1200,1120,1130,1900,2000]

Output:

3

Explanation:

Three trains overlap around 1100 hours.

Example 2:

Input:

arrivals = [100,110,120]
departures = [101,111,121]

Output:

1

Explanation:

Trains do not overlap; 1 platform suffices.

Loading...
Minimum Platforms Required - Intervals