Skip to content

Commit abe607d

Browse files
authored
Create 435-Non-Overlapping-Intervals.py
1 parent 5899e10 commit abe607d

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

435-Non-Overlapping-Intervals.py

+12
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
3+
intervals.sort()
4+
res = 0
5+
prevEnd = intervals[0][1]
6+
for start, end in intervals[1:]:
7+
if start >= prevEnd:
8+
prevEnd = end
9+
else:
10+
res += 1
11+
prevEnd = min(end, prevEnd)
12+
return res

0 commit comments

Comments
 (0)