LeetCode435. 无重叠区间
- 题目链接
- 代码
题目链接
https://leetcode.cn/problems/non-overlapping-intervals/
代码
class Solution:def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:if not intervals:return 0intervals.sort(key=lambda x: x[0])count = 0for i in range(1, len(intervals)):if intervals[i][0] < intervals[i - 1][1]:intervals[i][1] = min(intervals[i - 1][1], intervals[i][1])count += 1return count