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

Commit 6a14bc9

Browse files
committed
add 435
1 parent a425bf8 commit 6a14bc9

File tree

3 files changed

+55
-0
lines changed

3 files changed

+55
-0
lines changed
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
2+
# 0435.non-overlapping-intervals
3+
4+
给定一个区间的集合,找到需要移除区间的最小数量,使剩余区间互不重叠。
5+
6+
注意:
7+
8+
可以认为区间的终点总是大于它的起点。
9+
区间 [1,2][2,3] 的边界相互"接触",但没有相互重叠。
10+
11+
示例 1:
12+
13+
输入: [ [1,2], [2,3], [3,4], [1,3] ]
14+
15+
输出: 1
16+
17+
解释: 移除 [1,3] 后,剩下的区间没有重叠。
18+
19+
示例 2:
20+
21+
输入: [ [1,2], [1,2], [1,2] ]
22+
23+
输出: 2
24+
25+
解释: 你需要移除两个 [1,2] 来使剩下的区间没有重叠。
26+
27+
示例 3:
28+
29+
输入: [ [1,2], [2,3] ]
30+
31+
输出: 0
32+
33+
解释: 你不需要移除任何区间,因为它们已经是无重叠的了。
34+
35+
```text
36+
来源:力扣(LeetCode)
37+
链接:https://leetcode-cn.com/problems/non-overlapping-intervals
38+
著作权归领扣网络所有。商业转载请联系官方授权,非商业转载请注明出处。
39+
```
40+
41+
利用贪心方式让结尾最小的符合条件的优先保留,供后面的空间有更多的选择。
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
2+
package intervals
3+
4+
func Run() {
5+
6+
}
Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
2+
package intervals
3+
4+
import "testing"
5+
6+
func TestRun(t *testing.T) {
7+
Run()
8+
}

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /