题目
解法
把interval按照第一个元素生序第二个元素降序进行排序,逐个比较即可
class Solution:def removeCoveredIntervals(self, intervals: List[List[int]]) -> int:intervals.sort(key = lambda x:(x[0],-x[1]))# print(intervals)prev_end = intervals[0][1]ans = 0for inter in intervals[1:]:if inter[1] <= prev_end:ans += 1else:prev_end = inter[1]return len(intervals) - ans