类似于时刻安排表 最后的列表中每个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

本文介绍了一种用于最小化时间表中事件冲突的算法,通过将事件按结束时间排序并迭代检查,确保每个事件的结束时间尽可能提前,从而减少整体的时间冲突。此算法适用于需要高效管理时间表的应用场景。
499

被折叠的 条评论
为什么被折叠?



