← 返回 uber 的题目列表Meeting Scheduler: Minimum Number of Rooms
类型:online_judge
Implement a meeting-room scheduler. Given the start and end times of meetings, return the minimum number of rooms required to host every meeting.
A meeting is represented by a half-open interval [start, end): a room occupied until time end can be reused by another meeting beginning exactly at end. Therefore, [1, 5) and [5, 8) may use the same room.
Input Format
n
start1 end1
start2 end2
...
startn endn
Output Format
Print one integer: the minimum number of meeting rooms needed.
Constraints
0 <= n <= 100,000
0 <= start < end <= 10^9
Example
Input
3
0 30
5 10
15 20
Output
2
[0, 30) overlaps with both other meetings, so at least two rooms are required.
Example
Input
3
0 30
5 10
15 20
Output
2