题目:原题链接(中等)
解法 | 时间复杂度 | 空间复杂度 | 执行用时 |
---|---|---|---|
Ans 1 (Python) | O ( N l o g N ) O(NlogN) O(NlogN) | O ( l o g N ) O(logN) O(logN) | 52ms (50.73%) |
Ans 2 (Python) | |||
Ans 3 (Python) |
解法一:
class Solution:
def removeCoveredIntervals(self, intervals: List[List[int]]) -> int:
intervals.sort(key=lambda x: (x[0], -x[1]))
ans = len(intervals)
most_right = 0
for left, right in intervals:
if right <= most_right:
ans -= 1
else:
most_right = right
return ans