Skip to content

Commit 28a5579

Browse files
Solve : Non Overlapping Intervals
1 parent aae3ae1 commit 28a5579

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
from typing import List
2+
3+
class Solution:
4+
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
5+
intervals.sort(key=lambda x: x[1])
6+
count = 0
7+
end = float('-inf')
8+
for start, finish in intervals:
9+
if start < end:
10+
count += 1
11+
else:
12+
end = finish
13+
return count

0 commit comments

Comments
 (0)