← 返回 doordash 的题目列表Minimum Number of Couriers Needed (Meeting Rooms II Variant)
类型:online_judge
Problem
In a courier assignment setting, each order occupies one courier over a time interval [(start_i, end_i)] (clarify whether intervals are half-open or closed and be consistent).
Given n order intervals, a courier can handle at most one order at any time. Compute the minimum number of couriers required to cover all orders.
Input (stdin)
Line 1: integer n
Next n lines: two integers start_i end_i
Output (stdout)
Print one integer: the minimum number of couriers
Constraints
1 <= n <= 2*10^5
0 <= start_i < end_i <= 1e9
Example
Input:
3
0 30
5 10
15 20
Output:
2
Explanation: the maximum number of overlapping intervals is 2, so at least 2 couriers are needed.
Example
Input
3
0 30
5 10
15 20
Output
2