← 返回 netflix 的题目列表Maximum Overlap Among Closed Intervals
类型:online_judge
Problem: Maximum Overlap Among Closed Intervals
Given n closed intervals [start_i, end_i], where start_i <= end_i, a time point t is covered by [start_i, end_i] if and only if:
start_i <= t <= end_i
Return the maximum number of intervals that cover any single time point.
Pay special attention to the fact that intervals are closed. Therefore, [1, 3] and [3, 5] overlap at time 3.
Input Format
First line: an integer n
Next n lines: two integers start_i end_i, representing a closed interval [start_i, end_i]
Output Format
Print one integer: the maximum overlap count.
Constraints
1 <= n <= 2 * 10^5
0 <= start_i <= end_i <= 10^9
Interval endpoints may be duplicated.
Example 1
Input:
3
1 3
2 4
3 5
Output:
3
Explanation: All three closed intervals cover time 3.
Example 2
Input:
2
1 3
3 5
Output:
2
Explanation: The two closed intervals overlap at time 3.
Example
Input
3
1 3
2 4
3 5
Output
3