Skip to content

Commit fe3fdae

Browse files
committed
Time: 2294 ms (5.01%), Space: 56.2 MB (8.02%) - LeetHub
1 parent 19f3ddc commit fe3fdae

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
from typing import List
2+
3+
4+
class Solution:
5+
def eraseOverlapIntervals(self, intervals: List[List[int]]) -> int:
6+
7+
intervals.sort()
8+
answer = 0
9+
10+
prev_end = intervals[0][1]
11+
12+
for i in intervals[1:]:
13+
start, end = i[0], i[1]
14+
15+
if start >= prev_end:
16+
prev_end = end
17+
else:
18+
answer += 1
19+
prev_end = min(end, prev_end)
20+
21+
return answer

0 commit comments

Comments
 (0)