Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit11429cf

Browse files
authored
Create: 1288-remove-covered-intervals.py
1 parent80a12e6 commit11429cf

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
classSolution:
2+
defremoveCoveredIntervals(self,intervals:List[List[int]])->int:
3+
# sort on the basis of inc li first and then on the basis of dec length (=> -ri)
4+
intervals.sort(key=lambdax: (x[0],-x[1]))
5+
6+
covered,maxri=0,0
7+
8+
for_,riinintervals:
9+
ifri>maxri:
10+
maxri=ri
11+
else:
12+
covered+=1
13+
14+
returnlen(intervals)-covered

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp