题解 | #合并区间#
合并区间
http://www.nowcoder.com/practice/69f4e5b7ad284a478777cb2a17fb5e6a
class Solution: def merge(self , intervals ): # write code here intervals.sort(key=lambda x:x.start) merge = [] for interval in intervals: if not merge or merge[-1].end < interval.start: merge.append(interval) else: merge[-1].end = max(merge[-1].end,interval.end) return merge