← 返回 microsoft 的题目列表Merge Intervals
类型:online_judge
Given a collection of intervals, merge all overlapping intervals. Each interval is represented as a pair of integers, where the start and end are both inclusive.
Example
Input: [[1,3],[2,6],[8,10],[15,18]]
Output: [[1,6],[8,10],[15,18]]
Input: [[1,4],[4,5]]
Output: [[1,5]]
Note
The input intervals may not be in order.
Intervals with the same starting endpoint should be merged if possible.
Example
Input
[[1, 3], [2, 6], [8, 10], [15, 18]]