Skip to content

Commit 8f3e0ee

Browse files
committed
add 501,547,701710,741...
1 parent 212a9bb commit 8f3e0ee

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

58 files changed

+2583
-4735
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,6 @@ tmp/**/*
1414

1515
workspace/**/*
1616
!/workspace/.gitkeep
17+
18+
19+
playground/

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ node script deploy.sh
6060

6161
## 🔐 Problems & Solutions
6262

63-
完成进度([1036](./TOC-By-ID.md)🔑/ [2684](https://leetcode.cn/problemset/all/)🔒)
63+
完成进度([1047](./TOC-By-ID.md)🔑/ [2704](https://leetcode.cn/problemset/all/)🔒)
6464

6565
- 🔗 [标签查找](./TOC-By-Tag.md)
6666

TOC-By-ID.md

Lines changed: 553 additions & 547 deletions
Large diffs are not rendered by default.

TOC-By-Tag.md

Lines changed: 1640 additions & 1622 deletions
Large diffs are not rendered by default.
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# 线性DP
2+
3+
4+
5+
6+
7+
8+
9+
# 代码实现
10+
11+
12+
13+
```java
14+
class Solution {
15+
public int cherryPickup(int[][] g) {
16+
int m = g.length, n = g[0].length;
17+
int[][][] f = new int[75][75][75];
18+
int INF = Integer.MIN_VALUE;
19+
for (int k = 0; k < 75; k++)
20+
for (int i = 0; i < 75; i++)
21+
for (int j = 0; j < 75; j++)
22+
f[k][i][j] = INF;
23+
24+
f[1][1][n] = g[0][0] + g[0][n - 1];
25+
26+
for (int k = 2; k <= m; k++) {
27+
for (int i1 = 1; i1 <= n; i1++) {
28+
for (int i2 = 1; i2 <= n; i2++) {
29+
for (int d1 = i1 -1; d1 <= i1+1; d1++){
30+
for (int d2= i2-1; d2<= i2+1; d2++){
31+
f[k][i1][i2] = Math.max(f[k][i1][i2], f[k-1][d1][d2]);
32+
}
33+
}
34+
int A = g[k - 1][i1 - 1], B = g[k - 1][i2 - 1];
35+
f[k][i1][i2] += A;
36+
if (i1 != i2) f[k][i1][i2] += B;
37+
}
38+
}
39+
}
40+
41+
int ans = INF;
42+
for (int i = 1; i <= n; i++) {
43+
for (int j = 1; j <= n; j++) {
44+
ans = Math.max(ans, f[m][i][j]);
45+
}
46+
}
47+
return ans;
48+
}
49+
}
50+
51+
```
52+
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
2+
3+
4+
5+
6+
7+
8+
9+
10+
11+
# 暴力
12+
13+
14+
15+
16+
17+
18+
19+
20+
21+
# 前缀和
22+
23+
24+
25+
26+

algorithms/501-600/501.find-mode-in-binary-search-tree.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,4 @@
2828

2929
---
3030

31+

algorithms/501-600/547.number-of-provinces.md

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
班上有 N 名学生。其中有些人是朋友,有些则不是。他们的友谊具有是传递性。如果已知 A 是 B 的朋友,B 是 C 的朋友,那么我们可以认为 A 也是 C 的朋友。所谓的朋友圈,是指所有朋友的集合。
22

3-
给定一个 N * N 的矩阵 M,表示班级中学生之间的朋友关系。如果M[i][j] = 1,表示已知第 i 个和 j 个学生互为朋友关系,否则为不知道。你必须输出所有学生中的已知的朋友圈总数。
3+
给定一个 N * N 的矩阵 M,表示班级中学生之间的朋友关系。如果$M[i][j] = 1$,表示已知第 i 个和 j 个学生互为朋友关系,否则为不知道。你必须输出所有学生中的已知的朋友圈总数。
44

55
```cpp
66
示例 1:
@@ -16,11 +16,21 @@
1616

1717
---
1818

19-
### 解题思路
2019

21-
并查集求解
2220

23-
### 代码
21+
22+
23+
# 并查集
24+
25+
26+
27+
求连通块的个数
28+
29+
30+
31+
## 代码实现
32+
33+
2434

2535
初始朋友圈的数量为n, 每合并一次,减少一个朋友圈
2636

algorithms/701-800/701.insert-into-a-binary-search-tree.md

Whitespace-only changes.

algorithms/701-800/710.random-pick-with-blacklist.md

Whitespace-only changes.

0 commit comments

Comments
 (0)