-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy path435.py
More file actions
20 lines (18 loc) · 699 Bytes
/
Copy path435.py
File metadata and controls
20 lines (18 loc) · 699 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
"""Given an array of intervals intervals where intervals[i] = [starti, endi], return the minimum number of intervals you need to remove to make the rest of the intervals non-overlapping."""
class Solution:
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
intervals.sort(key=lambda x : x[1])
print(intervals)
print()
prev = 0
count = 0
for i in range(1, len(intervals)):
print(intervals[prev])
print(intervals[i])
print()
if intervals[i][0] < intervals[prev][1]:
count += 1
continue
else:
prev = i
return count