Bus i arrives at the depot at minute arrivals[i] and leaves at minute departures[i], occupying one bay for every minute from arrival to departure inclusive. If a bus departs at minute t and another arrives at minute t, they need different bays. Return the minimum number of bays so that no bus ever has to wait.
Examples
Input: arrivals = [10, 12, 12, 20, 25], departures = [15, 14, 30, 22, 25]
Output: 3
Explanation: At minute 12 three buses (10-15, 12-14, 12-30) are all in the depot.
Input: arrivals = [1, 5], departures = [5, 9]
Output: 2
Constraints
0 <= len(arrivals) == len(departures) <= 5 * 10**4,0 <= arrivals[i] <= departures[i] <= 10**9.- The lists are not sorted; index
iin both lists refers to the same bus. - Target complexity: O(n log n).
Goals
- Work with arrivals and departures given as two separate lists
- Release a bay only when a departure is strictly before the next arrival