NewThe Learning module is now liveSee what's new

(This question is a variation of the LeetCode question 253. Meeting Rooms II. If you haven't completed that question yet, it is recommended to solve it first.)

You are given a list of closed intervals on the number line, where each interval is represented as a pair [start, end] and includes both endpoints. Two intervals overlap at a point if that point lies in both intervals.

Determine the maximum number of intervals that overlap at any single point on the number line.

Constraints:

  • 1 ≤ intervals.length ≤ 10510^5
  • −109-10^9 ≤ intervals[i][0] ≤ intervals[i][1] ≤ 10910^9

Example 1:

Input: intervals = [[1, 3], [2, 5], [4, 6]] Output: 2 Explanation: At point 2, the first two intervals [1, 3] and [2, 5] overlap. At point 4, the last two intervals [2, 5] and [4, 6] overlap. And no single point is covered by all three intervals.

Example 2:

Input: intervals = [[1, 2], [3, 4], [5, 6]] Output: 1

Example 3:

Input: intervals = [[1, 10], [2, 5], [3, 7], [8, 9]] Output: 3


Accepted
1.7k/3.2k
Acceptance Rate53.4%
Test Cases
Input
intervals =
Output
Expected