You are given an array intervals, where intervals[i] = [start, end] is a time interval with start < end.
All 2n endpoint values are distinct: no two intervals share a start or end time.
Return the maximum number of intervals that are active at the same moment (an interval is active from its start until its end).
Examples
Example 1
Input: intervals = [[5,8],[2,4],[3,9]]
Output: 2
Explanation: Between times 5 and 8 both [5,8] and [3,9] are active. [2,4] overlaps only [3,9], so no moment has all three active.
Example 2
Input: intervals = [[1,10],[2,9],[3,8],[4,7]]
Output: 4
Explanation: The intervals are nested, so between times 4 and 7 all four are active.
Constraints
1≤intervals.length≤2⋅105
intervals[i].length=2
1≤start<end≤109
All 2n endpoint values are distinct.
Loading editor...
Log in to run your code. Your draft is saved in this browser.Log inSign up