leetcode435】的更多相关文章

Given a collection of intervals, find the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping. Note: You may assume the interval's end point is always bigger than its start point. Intervals like [1,2] and…
使用贪心思想,先按照end排序,然后依次寻找下一个(结束时前最早的)不重叠的区域,这样就得到了数量最多的构成不重叠的区域的数量,再用总数量减去最大不重叠区域的数量,就得到了最少的会引起重叠的区域的数量. class Solution: def eraseOverlapIntervals(self, intervals: 'List[Interval]') -> int: n = len(intervals) if n <= 1: return 0 l = sorted(intervals,ke…