From 287bd7bcb6b4fa2b64cea5ec2e6947f59e8c0126 Mon Sep 17 00:00:00 2001 From: yanglbme Date: Wed, 14 Aug 2024 19:02:24 +0800 Subject: [PATCH] feat: update lc problems --- .../0813.Largest Sum of Averages/README.md | 6 +- .../0813.Largest Sum of Averages/README_EN.md | 2 +- .../0814.Binary Tree Pruning/README_EN.md | 2 +- .../README.md | 2 +- .../1310.XOR Queries of a Subarray/README.md | 16 +- .../README_EN.md | 18 +- .../README.md | 2 +- .../README_EN.md | 6 +- .../2000-2099/2029.Stone Game IX/README.md | 4 +- .../2000-2099/2029.Stone Game IX/README_EN.md | 4 +- .../README.md | 226 ++++++++++++++++++ .../README_EN.md | 226 ++++++++++++++++++ .../Solution2.cpp | 40 ++++ .../Solution2.go | 37 +++ .../Solution2.java | 39 +++ .../Solution2.py | 30 +++ .../Solution2.ts | 41 ++++ .../README.md | 6 +- .../README.md | 5 + .../README_EN.md | 5 + .../3200-3299/3248.Snake in Matrix/README.md | 4 + .../3248.Snake in Matrix/README_EN.md | 4 + .../README.md | 3 + .../README_EN.md | 3 + .../README.md | 6 + .../README_EN.md | 6 + .../README.md | 6 + .../README_EN.md | 6 + .../README.md | 71 +++--- solution/DATABASE_README.md | 2 +- solution/DATABASE_README_EN.md | 2 +- solution/README.md | 12 +- solution/README_EN.md | 12 +- 33 files changed, 771 insertions(+), 83 deletions(-) create mode 100644 solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.cpp create mode 100644 solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.go create mode 100644 solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.java create mode 100644 solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.py create mode 100644 solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.ts diff --git a/solution/0800-0899/0813.Largest Sum of Averages/README.md b/solution/0800-0899/0813.Largest Sum of Averages/README.md index 3fac54601208e..8d0207f40fc92 100644 --- a/solution/0800-0899/0813.Largest Sum of Averages/README.md +++ b/solution/0800-0899/0813.Largest Sum of Averages/README.md @@ -31,9 +31,9 @@ tags:
 输入: nums = [9,1,2,3,9], k = 3
 输出: 20.00000
-解释:
-nums 的最优分组是[9], [1, 2, 3], [9]. 得到的分数是 9 + (1 + 2 + 3) / 3 + 9 = 20.
-我们也可以把 nums 分成[9, 1], [2], [3, 9].
+解释: 
+nums 的最优分组是[9], [1, 2, 3], [9]. 得到的分数是 9 + (1 + 2 + 3) / 3 + 9 = 20. 
+我们也可以把 nums 分成[9, 1], [2], [3, 9]. 
 这样的分组得到的分数为 5 + 2 + 6 = 13, 但不是最大值.
 
diff --git a/solution/0800-0899/0813.Largest Sum of Averages/README_EN.md b/solution/0800-0899/0813.Largest Sum of Averages/README_EN.md index 80fdbed7ec7b9..5b9f70f25a4c6 100644 --- a/solution/0800-0899/0813.Largest Sum of Averages/README_EN.md +++ b/solution/0800-0899/0813.Largest Sum of Averages/README_EN.md @@ -30,7 +30,7 @@ tags:
 Input: nums = [9,1,2,3,9], k = 3
 Output: 20.00000
-Explanation:
+Explanation: 
 The best choice is to partition nums into [9], [1, 2, 3], [9]. The answer is 9 + (1 + 2 + 3) / 3 + 9 = 20.
 We could have also partitioned nums into [9, 1], [2], [3, 9], for example.
 That partition would lead to a score of 5 + 2 + 6 = 13, which is worse.
diff --git a/solution/0800-0899/0814.Binary Tree Pruning/README_EN.md b/solution/0800-0899/0814.Binary Tree Pruning/README_EN.md
index eb5b39b48e3c7..85236c909250e 100644
--- a/solution/0800-0899/0814.Binary Tree Pruning/README_EN.md	
+++ b/solution/0800-0899/0814.Binary Tree Pruning/README_EN.md	
@@ -28,7 +28,7 @@ tags:
 
 Input: root = [1,null,0,0,1]
 Output: [1,null,0,null,1]
-Explanation:
+Explanation: 
 Only the red nodes satisfy the property "every subtree not containing a 1".
 The diagram on the right represents the answer.
 
diff --git a/solution/0800-0899/0849.Maximize Distance to Closest Person/README.md b/solution/0800-0899/0849.Maximize Distance to Closest Person/README.md index 3017704b4bd90..91d16e0603ca8 100644 --- a/solution/0800-0899/0849.Maximize Distance to Closest Person/README.md +++ b/solution/0800-0899/0849.Maximize Distance to Closest Person/README.md @@ -34,7 +34,7 @@ tags: 解释: 如果亚历克斯坐在第二个空位(seats[2])上,他到离他最近的人的距离为 2 。 如果亚历克斯坐在其它任何一个空位上,他到离他最近的人的距离为 1 。 -因此,他到离他最近的人的最大距离是 2 。 +因此,他到离他最近的人的最大距离是 2 。

示例 2:

diff --git a/solution/1300-1399/1310.XOR Queries of a Subarray/README.md b/solution/1300-1399/1310.XOR Queries of a Subarray/README.md index 995eb37827eee..8add1517a088d 100644 --- a/solution/1300-1399/1310.XOR Queries of a Subarray/README.md +++ b/solution/1300-1399/1310.XOR Queries of a Subarray/README.md @@ -32,17 +32,17 @@ tags:
 输入:arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]
-输出:[2,7,14,8]
+输出:[2,7,14,8] 
 解释:
 数组中元素的二进制表示形式是:
-1 = 0001
-3 = 0011
-4 = 0100
-8 = 1000
+1 = 0001 
+3 = 0011 
+4 = 0100 
+8 = 1000 
 查询的 XOR 值为:
-[0,1] = 1 xor 3 = 2
-[1,2] = 3 xor 4 = 7
-[0,3] = 1 xor 3 xor 4 xor 8 = 14
+[0,1] = 1 xor 3 = 2 
+[1,2] = 3 xor 4 = 7 
+[0,3] = 1 xor 3 xor 4 xor 8 = 14 
 [3,3] = 8
 
diff --git a/solution/1300-1399/1310.XOR Queries of a Subarray/README_EN.md b/solution/1300-1399/1310.XOR Queries of a Subarray/README_EN.md index 6248180574046..c43ab5ea6bd1d 100644 --- a/solution/1300-1399/1310.XOR Queries of a Subarray/README_EN.md +++ b/solution/1300-1399/1310.XOR Queries of a Subarray/README_EN.md @@ -31,17 +31,17 @@ tags:
 Input: arr = [1,3,4,8], queries = [[0,1],[1,2],[0,3],[3,3]]
-Output: [2,7,14,8]
-Explanation:
+Output: [2,7,14,8] 
+Explanation: 
 The binary representation of the elements in the array are:
-1 = 0001
-3 = 0011
-4 = 0100
-8 = 1000
+1 = 0001 
+3 = 0011 
+4 = 0100 
+8 = 1000 
 The XOR values for queries are:
-[0,1] = 1 xor 3 = 2
-[1,2] = 3 xor 4 = 7
-[0,3] = 1 xor 3 xor 4 xor 8 = 14
+[0,1] = 1 xor 3 = 2 
+[1,2] = 3 xor 4 = 7 
+[0,3] = 1 xor 3 xor 4 xor 8 = 14 
 [3,3] = 8
 
diff --git a/solution/1300-1399/1311.Get Watched Videos by Your Friends/README.md b/solution/1300-1399/1311.Get Watched Videos by Your Friends/README.md index 05386d827a14c..bc7fab1994d9e 100644 --- a/solution/1300-1399/1311.Get Watched Videos by Your Friends/README.md +++ b/solution/1300-1399/1311.Get Watched Videos by Your Friends/README.md @@ -37,7 +37,7 @@ tags:

输入:watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1
-输出:["B","C"]
+输出:["B","C"] 
 解释:
 你的 id 为 0(绿色),你的朋友包括(黄色):
 id 为 1 -> watchedVideos = ["C"] 
diff --git a/solution/1300-1399/1311.Get Watched Videos by Your Friends/README_EN.md b/solution/1300-1399/1311.Get Watched Videos by Your Friends/README_EN.md
index 1e52f27b051a5..c80bf64698ac8 100644
--- a/solution/1300-1399/1311.Get Watched Videos by Your Friends/README_EN.md	
+++ b/solution/1300-1399/1311.Get Watched Videos by Your Friends/README_EN.md	
@@ -33,8 +33,8 @@ tags:
 
 
 Input: watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 1
-Output: ["B","C"]
-Explanation:
+Output: ["B","C"] 
+Explanation: 
 You have id = 0 (green color in the figure) and your friends are (yellow color in the figure):
 Person with id = 1 -> watchedVideos = ["C"] 
 Person with id = 2 -> watchedVideos = ["B","C"] 
@@ -50,7 +50,7 @@ C -> 2
 
 Input: watchedVideos = [["A","B"],["C"],["B","C"],["D"]], friends = [[1,2],[0,3],[0,3],[1,2]], id = 0, level = 2
 Output: ["D"]
-Explanation:
+Explanation: 
 You have id = 0 (green color in the figure) and the only friend of your friends is the person with id = 3 (yellow color in the figure).
 
diff --git a/solution/2000-2099/2029.Stone Game IX/README.md b/solution/2000-2099/2029.Stone Game IX/README.md index 474e2578e74d8..2ec9b2248a1c1 100644 --- a/solution/2000-2099/2029.Stone Game IX/README.md +++ b/solution/2000-2099/2029.Stone Game IX/README.md @@ -42,7 +42,7 @@ tags: 输出:true 解释:游戏进行如下: - 回合 1:Alice 可以移除任意一个石子。 -- 回合 2:Bob 移除剩下的石子。 +- 回合 2:Bob 移除剩下的石子。 已移除的石子的值总和为 1 + 2 = 3 且可以被 3 整除。因此,Bob 输,Alice 获胜。
@@ -51,7 +51,7 @@ tags:
 输入:stones = [2]
 输出:false
-解释:Alice 会移除唯一一个石子,已移除石子的值总和为 2 。
+解释:Alice 会移除唯一一个石子,已移除石子的值总和为 2 。 
 由于所有石子都已移除,且值总和无法被 3 整除,Bob 获胜。
 
diff --git a/solution/2000-2099/2029.Stone Game IX/README_EN.md b/solution/2000-2099/2029.Stone Game IX/README_EN.md index 823e2d2d4ee8d..d3b055319b20b 100644 --- a/solution/2000-2099/2029.Stone Game IX/README_EN.md +++ b/solution/2000-2099/2029.Stone Game IX/README_EN.md @@ -36,7 +36,7 @@ tags: Output: true Explanation: The game will be played as follows: - Turn 1: Alice can remove either stone. -- Turn 2: Bob removes the remaining stone. +- Turn 2: Bob removes the remaining stone. The sum of the removed stones is 1 + 2 = 3 and is divisible by 3. Therefore, Bob loses and Alice wins the game.
@@ -45,7 +45,7 @@ The sum of the removed stones is 1 + 2 = 3 and is divisible by 3. Therefore, Bob
 Input: stones = [2]
 Output: false
-Explanation: Alice will remove the only stone, and the sum of the values on the removed stones is 2.
+Explanation: Alice will remove the only stone, and the sum of the values on the removed stones is 2. 
 Since all the stones are removed and the sum of values is not divisible by 3, Bob wins the game.
 
diff --git a/solution/2800-2899/2800.Shortest String That Contains Three Strings/README.md b/solution/2800-2899/2800.Shortest String That Contains Three Strings/README.md index 703812a4e9a58..6835bb8fd92c3 100644 --- a/solution/2800-2899/2800.Shortest String That Contains Three Strings/README.md +++ b/solution/2800-2899/2800.Shortest String That Contains Three Strings/README.md @@ -288,4 +288,230 @@ impl Solution { + + +### 方法二:枚举 + KMP + +我们可以使用 KMP 算法来优化字符串的合并过程。 + +时间复杂度 $O(n)$,空间复杂度 $O(n)$。其中 $n$ 是三个字符串的长度之和。 + + + +#### Python3 + +```python +class Solution: + def minimumString(self, a: str, b: str, c: str) -> str: + def f(s: str, t: str) -> str: + if s in t: + return t + if t in s: + return s + p = t + "#" + s + "$" + n = len(p) + next = [0] * n + next[0] = -1 + i, j = 2, 0 + while i < n: + if p[i - 1] == p[j]: + j += 1 + next[i] = j + i += 1 + elif j: + j = next[j] + else: + next[i] = 0 + i += 1 + return s + t[next[-1] :] + + ans = "" + for a, b, c in permutations((a, b, c)): + s = f(f(a, b), c) + if ans == "" or len(s) < len(ans) or (len(s) == len(ans) and s < ans): + ans = s + return ans +``` + +#### Java + +```java +class Solution { + public String minimumString(String a, String b, String c) { + String[] s = {a, b, c}; + int[][] perm = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}}; + String ans = ""; + for (var p : perm) { + int i = p[0], j = p[1], k = p[2]; + String t = f(f(s[i], s[j]), s[k]); + if ("".equals(ans) || t.length() < ans.length() + || (t.length() == ans.length() && t.compareTo(ans) < 0)) { + ans = t; + } + } + return ans; + } + + private String f(String s, String t) { + if (s.contains(t)) { + return s; + } + if (t.contains(s)) { + return t; + } + char[] p = (t + "#" + s + "$").toCharArray(); + int n = p.length; + int[] next = new int[n]; + next[0] = -1; + for (int i = 2, j = 0; i < n;) { + if (p[i - 1] == p[j]) { + next[i++] = ++j; + } else if (j > 0) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.substring(next[n - 1]); + } +} +``` + +#### C++ + +```cpp +class Solution { +public: + string minimumString(string a, string b, string c) { + vector s = {a, b, c}; + vector> perm = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}}; + string ans = ""; + for (auto& p : perm) { + int i = p[0], j = p[1], k = p[2]; + string t = f(f(s[i], s[j]), s[k]); + if (ans == "" || t.size() < ans.size() || (t.size() == ans.size() && t < ans)) { + ans = t; + } + } + return ans; + } + + string f(string s, string t) { + if (s.find(t) != string::npos) { + return s; + } + if (t.find(s) != string::npos) { + return t; + } + string p = t + "#" + s + "$"; + int n = p.size(); + int next[n]; + next[0] = -1; + next[1] = 0; + for (int i = 2, j = 0; i < n;) { + if (p[i - 1] == p[j]) { + next[i++] = ++j; + } else if (j > 0) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.substr(next[n - 1]); + }; +}; +``` + +#### Go + +```go +func minimumString(a string, b string, c string) string { + f := func(s, t string) string { + if strings.Contains(s, t) { + return s + } + if strings.Contains(t, s) { + return t + } + p := t + "#" + s + "$" + n := len(p) + next := make([]int, n) + next[0] = -1 + for i, j := 2, 0; i < n; { + if p[i-1] == p[j] { + j++ + next[i] = j + i++ + } else if j > 0 { + j = next[j] + } else { + next[i] = 0 + i++ + } + } + return s + t[next[n-1]:] + } + s := [3]string{a, b, c} + ans := "" + for _, p := range [][]int{{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}} { + i, j, k := p[0], p[1], p[2] + t := f(f(s[i], s[j]), s[k]) + if ans == "" || len(t) < len(ans) || (len(t) == len(ans) && t < ans) { + ans = t + } + } + return ans +} +``` + +#### TypeScript + +```ts +function minimumString(a: string, b: string, c: string): string { + const f = (s: string, t: string): string => { + if (s.includes(t)) { + return s; + } + if (t.includes(s)) { + return t; + } + const p = t + '#' + s + '$'; + const n = p.length; + const next: number[] = Array(n).fill(0); + next[0] = -1; + for (let i = 2, j = 0; i < n; ) { + if (p[i - 1] === p[j]) { + next[i++] = ++j; + } else if (j) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.slice(next[n - 1]); + }; + const s: string[] = [a, b, c]; + const perm: number[][] = [ + [0, 1, 2], + [0, 2, 1], + [1, 0, 2], + [1, 2, 0], + [2, 0, 1], + [2, 1, 0], + ]; + let ans = ''; + for (const [i, j, k] of perm) { + const t = f(f(s[i], s[j]), s[k]); + if (ans === '' || t.length < ans.length || (t.length === ans.length && t < ans)) { + ans = t; + } + } + return ans; +} +``` + + + + + diff --git a/solution/2800-2899/2800.Shortest String That Contains Three Strings/README_EN.md b/solution/2800-2899/2800.Shortest String That Contains Three Strings/README_EN.md index 3c56ba0479479..194cb863451b1 100644 --- a/solution/2800-2899/2800.Shortest String That Contains Three Strings/README_EN.md +++ b/solution/2800-2899/2800.Shortest String That Contains Three Strings/README_EN.md @@ -288,4 +288,230 @@ impl Solution { + + +### Solution 2: Enumeration + KMP + +We can use the KMP algorithm to optimize the string merging process. + +Time complexity is $O(n)$, and space complexity is $O(n)$. Here, $n$ is the sum of the lengths of the three strings. + + + +#### Python3 + +```python +class Solution: + def minimumString(self, a: str, b: str, c: str) -> str: + def f(s: str, t: str) -> str: + if s in t: + return t + if t in s: + return s + p = t + "#" + s + "$" + n = len(p) + next = [0] * n + next[0] = -1 + i, j = 2, 0 + while i < n: + if p[i - 1] == p[j]: + j += 1 + next[i] = j + i += 1 + elif j: + j = next[j] + else: + next[i] = 0 + i += 1 + return s + t[next[-1] :] + + ans = "" + for a, b, c in permutations((a, b, c)): + s = f(f(a, b), c) + if ans == "" or len(s) < len(ans) or (len(s) == len(ans) and s < ans): + ans = s + return ans +``` + +#### Java + +```java +class Solution { + public String minimumString(String a, String b, String c) { + String[] s = {a, b, c}; + int[][] perm = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}}; + String ans = ""; + for (var p : perm) { + int i = p[0], j = p[1], k = p[2]; + String t = f(f(s[i], s[j]), s[k]); + if ("".equals(ans) || t.length() < ans.length() + || (t.length() == ans.length() && t.compareTo(ans) < 0)) { + ans = t; + } + } + return ans; + } + + private String f(String s, String t) { + if (s.contains(t)) { + return s; + } + if (t.contains(s)) { + return t; + } + char[] p = (t + "#" + s + "$").toCharArray(); + int n = p.length; + int[] next = new int[n]; + next[0] = -1; + for (int i = 2, j = 0; i < n;) { + if (p[i - 1] == p[j]) { + next[i++] = ++j; + } else if (j > 0) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.substring(next[n - 1]); + } +} +``` + +#### C++ + +```cpp +class Solution { +public: + string minimumString(string a, string b, string c) { + vector s = {a, b, c}; + vector> perm = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}}; + string ans = ""; + for (auto& p : perm) { + int i = p[0], j = p[1], k = p[2]; + string t = f(f(s[i], s[j]), s[k]); + if (ans == "" || t.size() < ans.size() || (t.size() == ans.size() && t < ans)) { + ans = t; + } + } + return ans; + } + + string f(string s, string t) { + if (s.find(t) != string::npos) { + return s; + } + if (t.find(s) != string::npos) { + return t; + } + string p = t + "#" + s + "$"; + int n = p.size(); + int next[n]; + next[0] = -1; + next[1] = 0; + for (int i = 2, j = 0; i < n;) { + if (p[i - 1] == p[j]) { + next[i++] = ++j; + } else if (j > 0) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.substr(next[n - 1]); + }; +}; +``` + +#### Go + +```go +func minimumString(a string, b string, c string) string { + f := func(s, t string) string { + if strings.Contains(s, t) { + return s + } + if strings.Contains(t, s) { + return t + } + p := t + "#" + s + "$" + n := len(p) + next := make([]int, n) + next[0] = -1 + for i, j := 2, 0; i < n; { + if p[i-1] == p[j] { + j++ + next[i] = j + i++ + } else if j > 0 { + j = next[j] + } else { + next[i] = 0 + i++ + } + } + return s + t[next[n-1]:] + } + s := [3]string{a, b, c} + ans := "" + for _, p := range [][]int{{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}} { + i, j, k := p[0], p[1], p[2] + t := f(f(s[i], s[j]), s[k]) + if ans == "" || len(t) < len(ans) || (len(t) == len(ans) && t < ans) { + ans = t + } + } + return ans +} +``` + +#### TypeScript + +```ts +function minimumString(a: string, b: string, c: string): string { + const f = (s: string, t: string): string => { + if (s.includes(t)) { + return s; + } + if (t.includes(s)) { + return t; + } + const p = t + '#' + s + '$'; + const n = p.length; + const next: number[] = Array(n).fill(0); + next[0] = -1; + for (let i = 2, j = 0; i < n; ) { + if (p[i - 1] === p[j]) { + next[i++] = ++j; + } else if (j) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.slice(next[n - 1]); + }; + const s: string[] = [a, b, c]; + const perm: number[][] = [ + [0, 1, 2], + [0, 2, 1], + [1, 0, 2], + [1, 2, 0], + [2, 0, 1], + [2, 1, 0], + ]; + let ans = ''; + for (const [i, j, k] of perm) { + const t = f(f(s[i], s[j]), s[k]); + if (ans === '' || t.length < ans.length || (t.length === ans.length && t < ans)) { + ans = t; + } + } + return ans; +} +``` + + + + + diff --git a/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.cpp b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.cpp new file mode 100644 index 0000000000000..d07a8213f6bc7 --- /dev/null +++ b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.cpp @@ -0,0 +1,40 @@ +class Solution { +public: + string minimumString(string a, string b, string c) { + vector s = {a, b, c}; + vector> perm = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}}; + string ans = ""; + for (auto& p : perm) { + int i = p[0], j = p[1], k = p[2]; + string t = f(f(s[i], s[j]), s[k]); + if (ans == "" || t.size() < ans.size() || (t.size() == ans.size() && t < ans)) { + ans = t; + } + } + return ans; + } + + string f(string s, string t) { + if (s.find(t) != string::npos) { + return s; + } + if (t.find(s) != string::npos) { + return t; + } + string p = t + "#" + s + "$"; + int n = p.size(); + int next[n]; + next[0] = -1; + next[1] = 0; + for (int i = 2, j = 0; i < n;) { + if (p[i - 1] == p[j]) { + next[i++] = ++j; + } else if (j > 0) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.substr(next[n - 1]); + }; +}; diff --git a/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.go b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.go new file mode 100644 index 0000000000000..69277ed1cca05 --- /dev/null +++ b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.go @@ -0,0 +1,37 @@ +func minimumString(a string, b string, c string) string { + f := func(s, t string) string { + if strings.Contains(s, t) { + return s + } + if strings.Contains(t, s) { + return t + } + p := t + "#" + s + "$" + n := len(p) + next := make([]int, n) + next[0] = -1 + for i, j := 2, 0; i < n; { + if p[i-1] == p[j] { + j++ + next[i] = j + i++ + } else if j > 0 { + j = next[j] + } else { + next[i] = 0 + i++ + } + } + return s + t[next[n-1]:] + } + s := [3]string{a, b, c} + ans := "" + for _, p := range [][]int{{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 0, 1}, {2, 1, 0}} { + i, j, k := p[0], p[1], p[2] + t := f(f(s[i], s[j]), s[k]) + if ans == "" || len(t) < len(ans) || (len(t) == len(ans) && t < ans) { + ans = t + } + } + return ans +} diff --git a/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.java b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.java new file mode 100644 index 0000000000000..31a8d31b4f3a6 --- /dev/null +++ b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.java @@ -0,0 +1,39 @@ +class Solution { + public String minimumString(String a, String b, String c) { + String[] s = {a, b, c}; + int[][] perm = {{0, 1, 2}, {0, 2, 1}, {1, 0, 2}, {1, 2, 0}, {2, 1, 0}, {2, 0, 1}}; + String ans = ""; + for (var p : perm) { + int i = p[0], j = p[1], k = p[2]; + String t = f(f(s[i], s[j]), s[k]); + if ("".equals(ans) || t.length() < ans.length() + || (t.length() == ans.length() && t.compareTo(ans) < 0)) { + ans = t; + } + } + return ans; + } + + private String f(String s, String t) { + if (s.contains(t)) { + return s; + } + if (t.contains(s)) { + return t; + } + char[] p = (t + "#" + s + "$").toCharArray(); + int n = p.length; + int[] next = new int[n]; + next[0] = -1; + for (int i = 2, j = 0; i < n;) { + if (p[i - 1] == p[j]) { + next[i++] = ++j; + } else if (j > 0) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.substring(next[n - 1]); + } +} diff --git a/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.py b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.py new file mode 100644 index 0000000000000..7de9d467ba273 --- /dev/null +++ b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.py @@ -0,0 +1,30 @@ +class Solution: + def minimumString(self, a: str, b: str, c: str) -> str: + def f(s: str, t: str) -> str: + if s in t: + return t + if t in s: + return s + p = t + "#" + s + "$" + n = len(p) + next = [0] * n + next[0] = -1 + i, j = 2, 0 + while i < n: + if p[i - 1] == p[j]: + j += 1 + next[i] = j + i += 1 + elif j: + j = next[j] + else: + next[i] = 0 + i += 1 + return s + t[next[-1] :] + + ans = "" + for a, b, c in permutations((a, b, c)): + s = f(f(a, b), c) + if ans == "" or len(s) < len(ans) or (len(s) == len(ans) and s < ans): + ans = s + return ans diff --git a/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.ts b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.ts new file mode 100644 index 0000000000000..ecaffc506ee3d --- /dev/null +++ b/solution/2800-2899/2800.Shortest String That Contains Three Strings/Solution2.ts @@ -0,0 +1,41 @@ +function minimumString(a: string, b: string, c: string): string { + const f = (s: string, t: string): string => { + if (s.includes(t)) { + return s; + } + if (t.includes(s)) { + return t; + } + const p = t + '#' + s + '$'; + const n = p.length; + const next: number[] = Array(n).fill(0); + next[0] = -1; + for (let i = 2, j = 0; i < n; ) { + if (p[i - 1] === p[j]) { + next[i++] = ++j; + } else if (j) { + j = next[j]; + } else { + next[i++] = 0; + } + } + return s + t.slice(next[n - 1]); + }; + const s: string[] = [a, b, c]; + const perm: number[][] = [ + [0, 1, 2], + [0, 2, 1], + [1, 0, 2], + [1, 2, 0], + [2, 0, 1], + [2, 1, 0], + ]; + let ans = ''; + for (const [i, j, k] of perm) { + const t = f(f(s[i], s[j]), s[k]); + if (ans === '' || t.length < ans.length || (t.length === ans.length && t < ans)) { + ans = t; + } + } + return ans; +} diff --git a/solution/3200-3299/3235.Check if the Rectangle Corner Is Reachable/README.md b/solution/3200-3299/3235.Check if the Rectangle Corner Is Reachable/README.md index fc393593aa3be..1e5e11ea22948 100644 --- a/solution/3200-3299/3235.Check if the Rectangle Corner Is Reachable/README.md +++ b/solution/3200-3299/3235.Check if the Rectangle Corner Is Reachable/README.md @@ -21,9 +21,9 @@ tags: -

给你两个正整数 X 和 Y 和一个二维整数数组 circles ,其中 circles[i] = [xi, yi, ri] 表示一个圆心在 (xi, yi) 半径为 ri 的圆。

+

给你两个正整数 xCorner 和 yCorner 和一个二维整数数组 circles ,其中 circles[i] = [xi, yi, ri] 表示一个圆心在 (xi, yi) 半径为 ri 的圆。

-

坐标平面内有一个左下角在原点,右上角在 (X, Y) 的矩形。你需要判断是否存在一条从左下角到右上角的路径满足:路径 完全 在矩形内部,不会 触碰或者经过 任何 圆的内部和边界,同时  在起点和终点接触到矩形。

+

坐标平面内有一个左下角在原点,右上角在 (xCorner, yCorner) 的矩形。你需要判断是否存在一条从左下角到右上角的路径满足:路径 完全 在矩形内部,不会 触碰或者经过 任何 圆的内部和边界,同时  在起点和终点接触到矩形。

如果存在这样的路径,请你返回 true ,否则返回 false 。

@@ -88,7 +88,7 @@ tags:

提示:

    -
  • 3 <= X, Y <= 109
  • +
  • 3 <= xCorner, yCorner <= 109
  • 1 <= circles.length <= 1000
  • circles[i].length == 3
  • 1 <= xi, yi, ri <= 109
  • diff --git a/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README.md b/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README.md index ac085fbbc3384..b7a32c06fa19d 100644 --- a/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README.md +++ b/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README.md @@ -2,6 +2,11 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3247.Number%20of%20Subsequences%20with%20Odd%20Sum/README.md +tags: + - 数组 + - 数学 + - 动态规划 + - 组合数学 --- diff --git a/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README_EN.md b/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README_EN.md index 79a4e49627384..91342e9a0b9e3 100644 --- a/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README_EN.md +++ b/solution/3200-3299/3247.Number of Subsequences with Odd Sum/README_EN.md @@ -2,6 +2,11 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3247.Number%20of%20Subsequences%20with%20Odd%20Sum/README_EN.md +tags: + - Array + - Math + - Dynamic Programming + - Combinatorics --- diff --git a/solution/3200-3299/3248.Snake in Matrix/README.md b/solution/3200-3299/3248.Snake in Matrix/README.md index b77f4b733962a..321f12e83856b 100644 --- a/solution/3200-3299/3248.Snake in Matrix/README.md +++ b/solution/3200-3299/3248.Snake in Matrix/README.md @@ -2,6 +2,10 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3248.Snake%20in%20Matrix/README.md +tags: + - 数组 + - 字符串 + - 模拟 --- diff --git a/solution/3200-3299/3248.Snake in Matrix/README_EN.md b/solution/3200-3299/3248.Snake in Matrix/README_EN.md index b08375121cd2b..4973a21485aa5 100644 --- a/solution/3200-3299/3248.Snake in Matrix/README_EN.md +++ b/solution/3200-3299/3248.Snake in Matrix/README_EN.md @@ -2,6 +2,10 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3248.Snake%20in%20Matrix/README_EN.md +tags: + - Array + - String + - Simulation --- diff --git a/solution/3200-3299/3249.Count the Number of Good Nodes/README.md b/solution/3200-3299/3249.Count the Number of Good Nodes/README.md index f863e25fea1e8..ec3b3f0a8b8cc 100644 --- a/solution/3200-3299/3249.Count the Number of Good Nodes/README.md +++ b/solution/3200-3299/3249.Count the Number of Good Nodes/README.md @@ -2,6 +2,9 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3249.Count%20the%20Number%20of%20Good%20Nodes/README.md +tags: + - 树 + - 深度优先搜索 --- diff --git a/solution/3200-3299/3249.Count the Number of Good Nodes/README_EN.md b/solution/3200-3299/3249.Count the Number of Good Nodes/README_EN.md index b251ba71f7c7c..c2a8453e40fe8 100644 --- a/solution/3200-3299/3249.Count the Number of Good Nodes/README_EN.md +++ b/solution/3200-3299/3249.Count the Number of Good Nodes/README_EN.md @@ -2,6 +2,9 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3249.Count%20the%20Number%20of%20Good%20Nodes/README_EN.md +tags: + - Tree + - Depth-First Search --- diff --git a/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README.md b/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README.md index fb312a499e1b8..64fc72f3f4772 100644 --- a/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README.md +++ b/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3250.Find%20the%20Count%20of%20Monotonic%20Pairs%20I/README.md +tags: + - 数组 + - 数学 + - 动态规划 + - 组合数学 + - 前缀和 --- diff --git a/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README_EN.md b/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README_EN.md index c01cde5beb182..b0bdb02e099a6 100644 --- a/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README_EN.md +++ b/solution/3200-3299/3250.Find the Count of Monotonic Pairs I/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3250.Find%20the%20Count%20of%20Monotonic%20Pairs%20I/README_EN.md +tags: + - Array + - Math + - Dynamic Programming + - Combinatorics + - Prefix Sum --- diff --git a/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README.md b/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README.md index c1156c4d1d1cf..75da825a398e5 100644 --- a/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README.md +++ b/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3251.Find%20the%20Count%20of%20Monotonic%20Pairs%20II/README.md +tags: + - 数组 + - 数学 + - 动态规划 + - 组合数学 + - 前缀和 --- diff --git a/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README_EN.md b/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README_EN.md index 749b4f2cc9d23..9eed6d2d9fb0f 100644 --- a/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README_EN.md +++ b/solution/3200-3299/3251.Find the Count of Monotonic Pairs II/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3251.Find%20the%20Count%20of%20Monotonic%20Pairs%20II/README_EN.md +tags: + - Array + - Math + - Dynamic Programming + - Combinatorics + - Prefix Sum --- diff --git a/solution/3200-3299/3252.Premier League Table Ranking II/README.md b/solution/3200-3299/3252.Premier League Table Ranking II/README.md index d8614afd42fb2..73d28c3a7a83b 100644 --- a/solution/3200-3299/3252.Premier League Table Ranking II/README.md +++ b/solution/3200-3299/3252.Premier League Table Ranking II/README.md @@ -8,7 +8,7 @@ tags: -# [3252. Premier League Table Ranking II 🔒](https://leetcode.cn/problems/premier-league-table-ranking-ii) +# [3252. 英超积分榜排名 II 🔒](https://leetcode.cn/problems/premier-league-table-ranking-ii) [English Version](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README_EN.md) @@ -16,7 +16,7 @@ tags: -

    Table: TeamStats

    +

    表:TeamStats

     +------------------+---------+
    @@ -29,41 +29,42 @@ tags:
     | draws            | int     |
     | losses           | int     |
     +------------------+---------+
    -team_id is the unique key for this table.
    -This table contains team id, team name, matches_played, wins, draws, and losses.
    +team_id 是这张表的唯一主键。
    +这张表包含队伍 id,队伍名,场次,赢局,平局和输局。
     
    -

    Write a solution to calculate the points, position, and tier for each team in the league. Points are calculated as follows:

    +

    编写一个解决方案来计算联盟中每支球队的 得分排名 等级。积分计算方式如下:

      -
    • 3 points for a win
    • -
    • 1 point for a draw
    • -
    • 0 points for a loss
    • +
    • 赢局 有 3 点得分
    • +
    • 平局 有 1 点得分
    • +
    • 输局 有 0 点得分
    -

    Note: Teams with the same points must be assigned the same position.

    +

    注意:积分相同的球队必须分配相同的排名。

    -

    Tier ranking:

    +

    等级评级:

      -
    • Divide the league into 3 tiers based on points:
    • -
    • Tier 1: Top 33% of teams
    • -
    • Tier 2: Middle 33% of teams
    • -
    • Tier 3: Bottom 34% of teams
    • -
    • In case of ties at tier boundaries, place tied teams in the higher tier.
    • +
    • 根据积分将联盟分为 3 个等级:
    • +
    • 等级 1:前 33% 的队伍
    • +
    • 等级 2:中间 33% 的队伍
    • +
    • 等级 3:最后 34% 的队伍
    • +
    • 如果等级边界出现平局,平局的队伍分配到更高的等级。
    -

    Return the result table ordered by points in descending, and then by team_name in ascending order.

    +

    返回结果表以 points 降序 排序,然后以 team_name 升序 排序。

    -

    The query result format is in the following example.

    +

    结果格式如下所示。

     

    -

    Example:

    + +

    示例:

    -

    Input:

    +

    输入:

    -

    TeamStats table:

    +

    TeamStats 表:

     +---------+-------------------+----------------+------+-------+--------+
    @@ -82,7 +83,7 @@ This table contains team id, team name, matches_played, wins, draws, and losses.
     +---------+-------------------+----------------+------+-------+--------+
     
    -

    Output:

    +

    输出:

     +-------------------+--------+----------+---------+
    @@ -101,26 +102,26 @@ This table contains team id, team name, matches_played, wins, draws, and losses.
     +-------------------+--------+----------+---------+
     
    -

    Explanation:

    +

    解释:

      -
    • Sheffield United has 56 points (18 wins * 3 points + 2 draws * 1 point) and is in position 1.
    • -
    • Fulham has 55 points (18 wins * 3 points + 1 draw * 1 point) and is in position 2.
    • -
    • Newcastle United has 43 points (11 wins * 3 points + 10 draws * 1 point) and is in position 3.
    • -
    • Chelsea has 41 points (13 wins * 3 points + 2 draws * 1 point) and is in position 4.
    • -
    • Burnley has 27 points (6 wins * 3 points + 9 draws * 1 point) and is in position 5.
    • -
    • Nottingham Forest has 24 points (6 wins * 3 points + 6 draws * 1 point) and is in position 6.
    • -
    • Everton and Luton Town both have 12 points, with Everton having 2 wins * 3 points + 6 draws * 1 point, and Luton Town having 4 wins * 3 points. Both teams share position 7.
    • -
    • Liverpool has 11 points (1 win * 3 points + 8 draws * 1 point) and is in position 9.
    • -
    • Aston Villa has 9 points (1 win * 3 points + 6 draws * 1 point) and is in position 10.
    • +
    • 谢菲尔德联队拿下 56 分(18 胜 * 3 分 + 2 平 * 1 分)位列第 1。
    • +
    • 富勒姆拿下 55 分(18 胜 * 3 分 + 1 平 * 1 分)位列第 2。
    • +
    • 纽卡斯尔联队拿下 43 分(11 胜 * 3 分 + 10 平 * 1 分)位列第 3。
    • +
    • 切尔西拿下 41 分(13 胜 * 3 分 + 2 平 * 1 分)位列第 4。
    • +
    • 伯恩利拿下 27 分(6 胜 * 3 分 + 9 平 * 1 分)位列第 5。
    • +
    • 诺丁汉森林拿下 24 分(6 胜 * 3 分 + 6 平 * 1 分)位列第 6。
    • +
    • 埃弗顿和卢顿镇均拿下 12 分,埃弗顿 2 胜 * 3 分 + 6 平 * 1 分,卢顿镇 4 胜 * 3 分。两支队伍并列位列第 7。
    • +
    • 利物浦拿下 11 分(1 胜 * 3 分 + 8 平 * 1 分)位列第 9。
    • +
    • 阿斯顿维拉拿下 9 分(1 胜 * 3 分 + 6 平 * 1 分)位列第 10。
    -

    Tier Calculation:

    +

    等级计算:

      -
    • Tier 1: The top 33% of teams based on points. Sheffield United, Fulham, Newcastle United, and Chelsea fall into Tier 1.
    • -
    • Tier 2: The middle 33% of teams. Burnley, Nottingham Forest, Everton, and Luton Town fall into Tier 2.
    • -
    • Tier 3: The bottom 34% of teams. Liverpool and Aston Villa fall into Tier 3.
    • +
    • 等级 1:根据积分排名前 33% 的球队。谢菲尔德联队、富勒姆、纽卡斯尔联队和切尔西属于等级 1。
    • +
    • 等级 2:中间 33% 的球队。伯恩利、诺丁汉森林、埃弗顿和卢顿镇属于等级 2。
    • +
    • 等级 3:垫底 34% 的球队。利物浦和阿斯顿维拉落入等级 3。
    diff --git a/solution/DATABASE_README.md b/solution/DATABASE_README.md index 0d542f7ad18c6..49c1a0ea51466 100644 --- a/solution/DATABASE_README.md +++ b/solution/DATABASE_README.md @@ -291,7 +291,7 @@ | 3230 | [客户购买行为分析](/solution/3200-3299/3230.Customer%20Purchasing%20Behavior%20Analysis/README.md) | `数据库` | 中等 | 🔒 | | 3236 | [首席执行官下属层级](/solution/3200-3299/3236.CEO%20Subordinate%20Hierarchy/README.md) | `数据库` | 困难 | 🔒 | | 3246 | [英超积分榜排名](/solution/3200-3299/3246.Premier%20League%20Table%20Ranking/README.md) | `数据库` | 简单 | 🔒 | -| 3252 | [Premier League Table Ranking II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README.md) | | 中等 | 🔒 | +| 3252 | [英超积分榜排名 II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README.md) | `数据库` | 中等 | 🔒 | ## 版权 diff --git a/solution/DATABASE_README_EN.md b/solution/DATABASE_README_EN.md index baffed6b3a781..aa220ae281937 100644 --- a/solution/DATABASE_README_EN.md +++ b/solution/DATABASE_README_EN.md @@ -289,7 +289,7 @@ Press Control + F(or Command + F on | 3230 | [Customer Purchasing Behavior Analysis](/solution/3200-3299/3230.Customer%20Purchasing%20Behavior%20Analysis/README_EN.md) | `Database` | Medium | 🔒 | | 3236 | [CEO Subordinate Hierarchy](/solution/3200-3299/3236.CEO%20Subordinate%20Hierarchy/README_EN.md) | `Database` | Hard | 🔒 | | 3246 | [Premier League Table Ranking](/solution/3200-3299/3246.Premier%20League%20Table%20Ranking/README_EN.md) | `Database` | Easy | 🔒 | -| 3252 | [Premier League Table Ranking II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README_EN.md) | | Medium | 🔒 | +| 3252 | [Premier League Table Ranking II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README_EN.md) | `Database` | Medium | 🔒 | ## Copyright diff --git a/solution/README.md b/solution/README.md index ccfa154ee4700..c9792a8515323 100644 --- a/solution/README.md +++ b/solution/README.md @@ -3257,12 +3257,12 @@ | 3244 | [新增道路查询后的最短距离 II](/solution/3200-3299/3244.Shortest%20Distance%20After%20Road%20Addition%20Queries%20II/README.md) | `贪心`,`图`,`数组`,`有序集合` | 困难 | 第 409 场周赛 | | 3245 | [交替组 III](/solution/3200-3299/3245.Alternating%20Groups%20III/README.md) | `树状数组`,`数组` | 困难 | 第 409 场周赛 | | 3246 | [英超积分榜排名](/solution/3200-3299/3246.Premier%20League%20Table%20Ranking/README.md) | `数据库` | 简单 | 🔒 | -| 3247 | [奇数和子序列的数量](/solution/3200-3299/3247.Number%20of%20Subsequences%20with%20Odd%20Sum/README.md) | | 中等 | 🔒 | -| 3248 | [矩阵中的蛇](/solution/3200-3299/3248.Snake%20in%20Matrix/README.md) | | 简单 | 第 410 场周赛 | -| 3249 | [统计好节点的数目](/solution/3200-3299/3249.Count%20the%20Number%20of%20Good%20Nodes/README.md) | | 中等 | 第 410 场周赛 | -| 3250 | [单调数组对的数目 I](/solution/3200-3299/3250.Find%20the%20Count%20of%20Monotonic%20Pairs%20I/README.md) | | 困难 | 第 410 场周赛 | -| 3251 | [单调数组对的数目 II](/solution/3200-3299/3251.Find%20the%20Count%20of%20Monotonic%20Pairs%20II/README.md) | | 困难 | 第 410 场周赛 | -| 3252 | [Premier League Table Ranking II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README.md) | | 中等 | 🔒 | +| 3247 | [奇数和子序列的数量](/solution/3200-3299/3247.Number%20of%20Subsequences%20with%20Odd%20Sum/README.md) | `数组`,`数学`,`动态规划`,`组合数学` | 中等 | 🔒 | +| 3248 | [矩阵中的蛇](/solution/3200-3299/3248.Snake%20in%20Matrix/README.md) | `数组`,`字符串`,`模拟` | 简单 | 第 410 场周赛 | +| 3249 | [统计好节点的数目](/solution/3200-3299/3249.Count%20the%20Number%20of%20Good%20Nodes/README.md) | `树`,`深度优先搜索` | 中等 | 第 410 场周赛 | +| 3250 | [单调数组对的数目 I](/solution/3200-3299/3250.Find%20the%20Count%20of%20Monotonic%20Pairs%20I/README.md) | `数组`,`数学`,`动态规划`,`组合数学`,`前缀和` | 困难 | 第 410 场周赛 | +| 3251 | [单调数组对的数目 II](/solution/3200-3299/3251.Find%20the%20Count%20of%20Monotonic%20Pairs%20II/README.md) | `数组`,`数学`,`动态规划`,`组合数学`,`前缀和` | 困难 | 第 410 场周赛 | +| 3252 | [英超积分榜排名 II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README.md) | `数据库` | 中等 | 🔒 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index ccedbcd345383..4c818e2d17786 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -3255,12 +3255,12 @@ Press Control + F(or Command + F on | 3244 | [Shortest Distance After Road Addition Queries II](/solution/3200-3299/3244.Shortest%20Distance%20After%20Road%20Addition%20Queries%20II/README_EN.md) | `Greedy`,`Graph`,`Array`,`Ordered Set` | Hard | Weekly Contest 409 | | 3245 | [Alternating Groups III](/solution/3200-3299/3245.Alternating%20Groups%20III/README_EN.md) | `Binary Indexed Tree`,`Array` | Hard | Weekly Contest 409 | | 3246 | [Premier League Table Ranking](/solution/3200-3299/3246.Premier%20League%20Table%20Ranking/README_EN.md) | `Database` | Easy | 🔒 | -| 3247 | [Number of Subsequences with Odd Sum](/solution/3200-3299/3247.Number%20of%20Subsequences%20with%20Odd%20Sum/README_EN.md) | | Medium | 🔒 | -| 3248 | [Snake in Matrix](/solution/3200-3299/3248.Snake%20in%20Matrix/README_EN.md) | | Easy | Weekly Contest 410 | -| 3249 | [Count the Number of Good Nodes](/solution/3200-3299/3249.Count%20the%20Number%20of%20Good%20Nodes/README_EN.md) | | Medium | Weekly Contest 410 | -| 3250 | [Find the Count of Monotonic Pairs I](/solution/3200-3299/3250.Find%20the%20Count%20of%20Monotonic%20Pairs%20I/README_EN.md) | | Hard | Weekly Contest 410 | -| 3251 | [Find the Count of Monotonic Pairs II](/solution/3200-3299/3251.Find%20the%20Count%20of%20Monotonic%20Pairs%20II/README_EN.md) | | Hard | Weekly Contest 410 | -| 3252 | [Premier League Table Ranking II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README_EN.md) | | Medium | 🔒 | +| 3247 | [Number of Subsequences with Odd Sum](/solution/3200-3299/3247.Number%20of%20Subsequences%20with%20Odd%20Sum/README_EN.md) | `Array`,`Math`,`Dynamic Programming`,`Combinatorics` | Medium | 🔒 | +| 3248 | [Snake in Matrix](/solution/3200-3299/3248.Snake%20in%20Matrix/README_EN.md) | `Array`,`String`,`Simulation` | Easy | Weekly Contest 410 | +| 3249 | [Count the Number of Good Nodes](/solution/3200-3299/3249.Count%20the%20Number%20of%20Good%20Nodes/README_EN.md) | `Tree`,`Depth-First Search` | Medium | Weekly Contest 410 | +| 3250 | [Find the Count of Monotonic Pairs I](/solution/3200-3299/3250.Find%20the%20Count%20of%20Monotonic%20Pairs%20I/README_EN.md) | `Array`,`Math`,`Dynamic Programming`,`Combinatorics`,`Prefix Sum` | Hard | Weekly Contest 410 | +| 3251 | [Find the Count of Monotonic Pairs II](/solution/3200-3299/3251.Find%20the%20Count%20of%20Monotonic%20Pairs%20II/README_EN.md) | `Array`,`Math`,`Dynamic Programming`,`Combinatorics`,`Prefix Sum` | Hard | Weekly Contest 410 | +| 3252 | [Premier League Table Ranking II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README_EN.md) | `Database` | Medium | 🔒 | ## Copyright