Python | Leetcode Python题解之第435题无重叠区间
题目:
题解:
class Solution:def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:if not intervals:return 0intervals.sort(key=lambda x: x[1])n = len(intervals)right = intervals[0][1]ans = 1for i in range(1, n):if intervals[i][0] >= right:ans += 1right = intervals[i][1]return n - ans