← 返回 amazon 的题目列表Merge Intervals
类型:online_judge
Given a collection of intervals, merge all overlapping intervals. Each interval is represented as a list of two integers, the start and end. Return the merged intervals sorted by the starting values.
Example:
Input: intervals = [ [1, 3], [2, 6], [8, 10], [15, 18] ]
Output: [ [1, 6], [8, 10], [15, 18] ]
Explanation: Intervals [1, 3] and [2, 6] overlap and are merged into [1, 6].
Example
Input
[(1, 3), (2, 6), (8, 10), (15, 18)]