Active Couriers Timeline
Examples
Example 1:
Input: couriers = [[1,5],[3,7]]
Output: [[1,3,1],[3,5,2],[5,7,1]]
Explanation:
Example 2:
Input: couriers = [[1,3],[3,5],[3,6]]
Output: [[1,3,1],[3,5,2],[5,6,1]]
Explanation:
Example 1:
Input: couriers = [[1,5],[3,7]]
Output: [[1,3,1],[3,5,2],[5,7,1]]
Explanation:
Example 2:
Input: couriers = [[1,3],[3,5],[3,6]]
Output: [[1,3,1],[3,5,2],[5,6,1]]
Explanation:
You are given couriers, where couriers[i] = [start, end] represents the working interval of the ith courier. start is inclusive and end is exclusive.
Intervals may overlap. Return a list of timeline segments [segmentStart, segmentEnd, activeCount] such that:
activeCount is the number of couriers working throughout the entire segment.activeCount > 0 should appear in the output.If multiple couriers start or end at the same time, treat all changes at that timestamp together before moving to the next segment.
From 1 to 3, one courier is active. From 3 to 5, both are active. From 5 to 7, only the second courier remains.
Because intervals are [start, end), the courier ending at 3 is not active at time 3, while the two couriers starting at 3 are.
1 <= couriers.length <= 10^5couriers[i].length == 20 <= start < end <= 10^9