← 返回 amazon 的题目列表Count Number of Packages
类型:online_judge
Given an array where each element is a start and end position (start, end), find out how many packages there are. These packages are denoted by |*|, and they can overlap. Write a function to calculate the total number of packages and their specific start and end positions.
Input
An integer n, the number of elements in the array.
The next n lines, each containing two integers start_i and end_i, representing the start and end positions of the i-th package.
Output
An integer, indicating the total number of packages considering overlaps.
Constraints
1 <= n <= 10^5
0 <= start_i <= end_i < 10^9
Example
Input
3
1 4
2 5
3 6
Output
3
Example
Input
3
1 4
2 5
3 6