← 返回 nvidia 的题目列表Merge Intervals
类型:online_judge
Problem: Merge Intervals
Given an array of closed intervals intervals, where each interval is represented as [start, end], merge all overlapping intervals and return a list of non-overlapping intervals sorted by start time.
Input Format
The first line contains an integer n, the number of intervals.
The next n lines each contain two integers start end.
Output Format
Print the merged intervals, one interval per line, as start end.
The output should be sorted by start in ascending order.
Constraints
0 <= n <= 10^5
-10^9 <= start <= end <= 10^9
Example
Input
4
1 3
2 6
8 10
15 18
Output
1 6
8 10
15 18