Minimum Platforms
The paired integer arrays Arrival and Departure describe trains present at a station during one day. Return the minimum number of platforms needed so that no…
The paired integer arrays `Arrival` and `Departure` describe trains present at a station during one day. Return the minimum number of platforms needed so that no train waits. Both endpoints of each interval are occupied: an arrival at the same time as another train's departure needs a different platform. Time values are ordered numeric labels in 0..2359; no hour/minute subfield interpretation is required.
- 1 <= Arrival.length = Departure.length <= 100000 - 0 <= Arrival[i] <= Departure[i] <= 2359 - Intervals include both endpoints. Equal arrival and departure times overlap. - The teaching trace accepts at most 8 trains; coding retains the full bounds.
Example 1: input Arrival = [900,940,950,1100,1500,1800], Departure = [910,1200,1120,1130,1900,2000]; output 3. At time 1100, three train intervals overlap.
Example 2: input Arrival = [900,1100,1235], Departure = [1000,1200,1240]; output 1. No two intervals overlap.
Example 3: input Arrival = [900,1000], Departure = [1000,1100]; output 2. At the shared endpoint 1000, both trains need a platform.
Category: Greedy Algorithms. Topic: greedy. Difficulty: Medium. Patterns: greedy, sorting.