435. Non-overlapping Intervals
class Solution:
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
intervals.sort(key=lambda x: (x[1],x[0]))
# heap = [float('inf')]
pre = float('-inf')
res = 0
for i in range(len(intervals)):
if intervals[i][0] < pre:
res += 1
else:
pre = intervals[i][1]
# heappush(heap, -intervals[i][1])
return res