← 返回 jpmorgan 的题目列表Minimum Meeting Rooms / Minimum CPUs for Tasks
类型:online_judge
You are given a list of time intervals intervals, each interval represented as [start, end) (start inclusive, end exclusive). A single meeting room/CPU cannot host overlapping intervals at the same time.
Compute the minimum number of resources required to process all intervals:
minimum meeting rooms (Meeting Rooms), or
minimum CPUs (same problem, just different wording).
Input
Line 1: integer n, the number of intervals.
Next n lines: two integers start end.
Output
One integer: the minimum number of rooms/CPUs required.
Constraints
1 <= n <= 2*10^5
0 <= start < end <= 10^9
Sample Tests
Input:
3
0 30
5 10
15 20
Output:
2
Input:
3
7 10
2 4
11 12
Output:
1
Input:
4
1 5
2 6
4 8
7 9
Output:
3
Input:
5
1 2
2 3
3 4
4 5
5 6
Output:
1
Input:
6
1 10
2 3
3 4
4 5
5 6
6 7
Output:
2
```,
Example
Input
3
0 30
5 10
15 20
Output
2