Merge Intervals
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Example 2:
思路是,先按interval的左端(start)排序。然后一个个检查是否能合并。下面这个做 in place 的替换。extra space O(1)
九章的一个solution
Last updated
Was this helpful?
Given a collection of intervals, merge all overlapping intervals.
Example 1:
Example 2:
思路是,先按interval的左端(start)排序。然后一个个检查是否能合并。下面这个做 in place 的替换。extra space O(1)
九章的一个solution
Last updated
Was this helpful?