类似于时刻安排表 最后的列表中每个end应该尽量要小
44ms 100%
class Solution:
def eraseOverlapIntervals(self, intervals):
"""
:type intervals: List[Interval]
:rtype: int
"""
newIn=sorted(intervals,key=lambda intervals:intervals.end)
count=0
lastend=None
for n in newIn:
if lastend==None:
lastend=n.end
else:
if n.end==lastend or n.start<lastend:
count+=1
else:
lastend=n.end
return count