Minimum Railway Platforms
Problem statement
Given equal-length arrays of train arrival and departure times, return the minimum number of station platforms required so that no train waits.
Each pair at the same index describes one train. Time values are comparable integers on one day. If one train arrives at the exact time another departs, both occupy a platform at that instant, so the arrival is processed first.
Function
minimumPlatforms(arrivals: int[], departures: int[]) → intExamples
Example 1
arrivals = [900,940,950,1100,1500,1800]departures = [910,1200,1120,1130,1900,2000]return = 3Three trains overlap around time 1100.
Example 2
arrivals = [900,1100,1235]departures = [1000,1200,1240]return = 1No two train intervals overlap.
Constraints
1 <= arrivals.length == departures.length <= 2000000 <= arrivals[i] <= departures[i] <= 10^9- All times belong to one comparable timeline.
Source note: Interview prompt excerpt preserved as source evidence.