diff --git a/solution/0000-0099/0020.Valid Parentheses/README.md b/solution/0000-0099/0020.Valid Parentheses/README.md index 4e6adcb27adec..e4c364fe798a6 100644 --- a/solution/0000-0099/0020.Valid Parentheses/README.md +++ b/solution/0000-0099/0020.Valid Parentheses/README.md @@ -29,26 +29,37 @@ tags:

 

-

示例 1:

+

示例 1:

-
-输入:s = "()"
-输出:true
-
+
+

输入:s = "()"

-

示例 2:

+

输出:true

+
-
-输入:s = "()[]{}"
-输出:true
-
+

示例 2:

-

示例 3:

+
+

输入:s = "()[]{}"

-
-输入:s = "(]"
-输出:false
-
+

输出:true

+
+ +

示例 3:

+ +
+

输入:s = "(]"

+ +

输出:false

+
+ +

示例 4:

+ +
+

输入:s = "([])"

+ +

输出:true

+

 

diff --git a/solution/0100-0199/0176.Second Highest Salary/README.md b/solution/0100-0199/0176.Second Highest Salary/README.md index 7e2f110891385..186c1cb8fa9d1 100644 --- a/solution/0100-0199/0176.Second Highest Salary/README.md +++ b/solution/0100-0199/0176.Second Highest Salary/README.md @@ -27,13 +27,13 @@ tags: | id | int | | salary | int | +-------------+------+ -在 SQL 中,id 是这个表的主键。 +id 是这个表的主键。 表的每一行包含员工的工资信息。

 

-

查询并返回 Employee 表中第二高的薪水 。如果不存在第二高的薪水,查询应该返回 null(Pandas 则返回 None)

+

查询并返回 Employee 表中第二高的 不同 薪水 。如果不存在第二高的薪水,查询应该返回 null(Pandas 则返回 None)

查询结果如下例所示。

diff --git a/solution/0100-0199/0176.Second Highest Salary/README_EN.md b/solution/0100-0199/0176.Second Highest Salary/README_EN.md index dc497121217dd..dc07f75586d2b 100644 --- a/solution/0100-0199/0176.Second Highest Salary/README_EN.md +++ b/solution/0100-0199/0176.Second Highest Salary/README_EN.md @@ -31,7 +31,7 @@ Each row of this table contains information about the salary of an employee.

 

-

Write a solution to find the second highest salary from the Employee table. If there is no second highest salary, return null (return None in Pandas).

+

Write a solution to find the second highest distinct salary from the Employee table. If there is no second highest salary, return null (return None in Pandas).

The result format is in the following example.

diff --git a/solution/0100-0199/0197.Rising Temperature/README_EN.md b/solution/0100-0199/0197.Rising Temperature/README_EN.md index 5902232ce59ae..cfcc012acfc2d 100644 --- a/solution/0100-0199/0197.Rising Temperature/README_EN.md +++ b/solution/0100-0199/0197.Rising Temperature/README_EN.md @@ -33,7 +33,7 @@ This table contains information about the temperature on a certain day.

 

-

Write a solution to find all dates' Id with higher temperatures compared to its previous dates (yesterday).

+

Write a solution to find all dates' id with higher temperatures compared to its previous dates (yesterday).

Return the result table in any order.

diff --git a/solution/0200-0299/0205.Isomorphic Strings/README_EN.md b/solution/0200-0299/0205.Isomorphic Strings/README_EN.md index 0b05304ac08f9..2f3eb16d4b8b7 100644 --- a/solution/0200-0299/0205.Isomorphic Strings/README_EN.md +++ b/solution/0200-0299/0205.Isomorphic Strings/README_EN.md @@ -25,15 +25,42 @@ tags:

 

Example 1:

-
Input: s = "egg", t = "add"
-Output: true
-

Example 2:

-
Input: s = "foo", t = "bar"
-Output: false
-

Example 3:

-
Input: s = "paper", t = "title"
-Output: true
-
+ +
+

Input: s = "egg", t = "add"

+ +

Output: true

+ +

Explanation:

+ +

The strings s and t can be made identical by:

+ + +
+ +

Example 2:

+ +
+

Input: s = "foo", t = "bar"

+ +

Output: false

+ +

Explanation:

+ +

The strings s and t can not be made identical as 'o' needs to be mapped to both 'a' and 'r'.

+
+ +

Example 3:

+ +
+

Input: s = "paper", t = "title"

+ +

Output: true

+
+

 

Constraints:

diff --git a/solution/0200-0299/0242.Valid Anagram/README.md b/solution/0200-0299/0242.Valid Anagram/README.md index 45b5a4d81a9c8..ffd047fc8c537 100644 --- a/solution/0200-0299/0242.Valid Anagram/README.md +++ b/solution/0200-0299/0242.Valid Anagram/README.md @@ -20,11 +20,11 @@ tags:

给定两个字符串 st ,编写一个函数来判断 t 是否是 s 的字母异位词。

-

注意:若 st 中每个字符出现的次数都相同,则称 st 互为字母异位词。

+

字母异位词 是通过重新排列不同单词或短语的字母而形成的单词或短语,通常只使用所有原始字母一次。

-

 

+

 

-

示例 1:

+

示例 1:

 输入: s = "anagram", t = "nagaram"
@@ -37,18 +37,18 @@ tags:
 输入: s = "rat", t = "car"
 输出: false
-

 

+

 

提示:

-

 

+

 

-

进阶: 如果输入字符串包含 unicode 字符怎么办?你能否调整你的解法来应对这种情况?

+

进阶: 如果输入字符串包含 unicode 字符怎么办?你能否调整你的解法来应对这种情况?

diff --git a/solution/0400-0499/0455.Assign Cookies/README.md b/solution/0400-0499/0455.Assign Cookies/README.md index b5b132e42c223..8d64455509043 100644 --- a/solution/0400-0499/0455.Assign Cookies/README.md +++ b/solution/0400-0499/0455.Assign Cookies/README.md @@ -21,7 +21,7 @@ tags:

假设你是一位很棒的家长,想要给你的孩子们一些小饼干。但是,每个孩子最多只能给一块饼干。

-

对每个孩子 i,都有一个胃口值 g[i]这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j,都有一个尺寸 s[j] 。如果 s[j] >= g[i],我们可以将这个饼干 j 分配给孩子 i ,这个孩子会得到满足。你的目标是尽可能满足越多数量的孩子,并输出这个最大数值。

+

对每个孩子 i,都有一个胃口值 g[i]这是能让孩子们满足胃口的饼干的最小尺寸;并且每块饼干 j,都有一个尺寸 s[j] 。如果 s[j] >= g[i],我们可以将这个饼干 j 分配给孩子 i ,这个孩子会得到满足。你的目标是满足尽可能多的孩子,并输出这个最大数值。

 

示例 1:

diff --git a/solution/0500-0599/0592.Fraction Addition and Subtraction/README.md b/solution/0500-0599/0592.Fraction Addition and Subtraction/README.md index f3014f3f82008..d6f2bc1fcfebd 100644 --- a/solution/0500-0599/0592.Fraction Addition and Subtraction/README.md +++ b/solution/0500-0599/0592.Fraction Addition and Subtraction/README.md @@ -20,7 +20,7 @@ tags:

给定一个表示分数加减运算的字符串 expression ,你需要返回一个字符串形式的计算结果。 

-

这个结果应该是不可约分的分数,即最简分数。 如果最终结果是一个整数,例如 2,你需要将它转换成分数形式,其分母为 1。所以在上述例子中, 2 应该被转换为 2/1

+

这个结果应该是不可约分的分数,即 最简分数。 如果最终结果是一个整数,例如 2,你需要将它转换成分数形式,其分母为 1。所以在上述例子中, 2 应该被转换为 2/1

 

@@ -52,9 +52,9 @@ tags: diff --git a/solution/0600-0699/0626.Exchange Seats/README.md b/solution/0600-0699/0626.Exchange Seats/README.md index 5cae44413126e..60214d85f7b02 100644 --- a/solution/0600-0699/0626.Exchange Seats/README.md +++ b/solution/0600-0699/0626.Exchange Seats/README.md @@ -27,7 +27,7 @@ tags: +-------------+---------+ id 是该表的主键(唯一值)列。 该表的每一行都表示学生的姓名和 ID。 -id 是一个连续的增量。 +ID 序列始终从 1 开始并连续增加。

 

diff --git a/solution/0600-0699/0673.Number of Longest Increasing Subsequence/README_EN.md b/solution/0600-0699/0673.Number of Longest Increasing Subsequence/README_EN.md index 4ed3e06931683..52b28ef54f311 100644 --- a/solution/0600-0699/0673.Number of Longest Increasing Subsequence/README_EN.md +++ b/solution/0600-0699/0673.Number of Longest Increasing Subsequence/README_EN.md @@ -46,6 +46,7 @@ tags: diff --git a/solution/0700-0799/0728.Self Dividing Numbers/README.md b/solution/0700-0799/0728.Self Dividing Numbers/README.md index 28b66a5626026..f883b21f46fba 100644 --- a/solution/0700-0799/0728.Self Dividing Numbers/README.md +++ b/solution/0700-0799/0728.Self Dividing Numbers/README.md @@ -24,7 +24,7 @@ tags:

自除数 不允许包含 0 。

-

给定两个整数 left 和 right ,返回一个列表,列表的元素是范围 [left, right] 内所有的 自除数

+

给定两个整数 left 和 right ,返回一个列表,列表的元素是范围 [left, right](包括两个端点)内所有的 自除数

 

diff --git a/solution/0700-0799/0728.Self Dividing Numbers/README_EN.md b/solution/0700-0799/0728.Self Dividing Numbers/README_EN.md index c26e0dc44b1af..99af263bf3e85 100644 --- a/solution/0700-0799/0728.Self Dividing Numbers/README_EN.md +++ b/solution/0700-0799/0728.Self Dividing Numbers/README_EN.md @@ -24,7 +24,7 @@ tags:

A self-dividing number is not allowed to contain the digit zero.

-

Given two integers left and right, return a list of all the self-dividing numbers in the range [left, right].

+

Given two integers left and right, return a list of all the self-dividing numbers in the range [left, right] (both inclusive).

 

Example 1:

diff --git a/solution/0800-0899/0840.Magic Squares In Grid/README.md b/solution/0800-0899/0840.Magic Squares In Grid/README.md index 2e9b56973f791..5ec1db887dc13 100644 --- a/solution/0800-0899/0840.Magic Squares In Grid/README.md +++ b/solution/0800-0899/0840.Magic Squares In Grid/README.md @@ -21,7 +21,7 @@ tags:

3 x 3 的幻方是一个填充有 19  的不同数字的 3 x 3 矩阵,其中每行,每列以及两条对角线上的各数之和都相等。

-

给定一个由整数组成的row x col 的 grid,其中有多少个 3 × 3 的 “幻方” 子矩阵?(每个子矩阵都是连续的)。

+

给定一个由整数组成的row x col 的 grid,其中有多少个 3 × 3 的 “幻方” 子矩阵?

注意:虽然幻方只能包含 1 到 9 的数字,但 grid 可以包含最多15的数字。

diff --git a/solution/0900-0999/0909.Snakes and Ladders/README.md b/solution/0900-0999/0909.Snakes and Ladders/README.md index ca54cfefe425b..131d16da3ae80 100644 --- a/solution/0900-0999/0909.Snakes and Ladders/README.md +++ b/solution/0900-0999/0909.Snakes and Ladders/README.md @@ -18,14 +18,12 @@ tags: -

给你一个大小为 n x n 的整数矩阵 board ,方格按从 1n2 编号,编号遵循 转行交替方式 从左下角开始 (即,从 board[n - 1][0] 开始)每一行交替方向。

+

给你一个大小为 n x n 的整数矩阵 board ,方格按从 1n2 编号,编号遵循 转行交替方式 从左下角开始 (即,从 board[n - 1][0] 开始)的每一行改变方向。

-

玩家从棋盘上的方格 1 (总是在最后一行、第一列)开始出发。

- -

每一回合,玩家需要从当前方格 curr 开始出发,按下述要求前进:

+

你一开始位于棋盘上的方格  1。每一回合,玩家需要从当前方格 curr 开始出发,按下述要求前进:

diff --git a/solution/2000-2099/2037.Minimum Number of Moves to Seat Everyone/README_EN.md b/solution/2000-2099/2037.Minimum Number of Moves to Seat Everyone/README_EN.md index 5536dd52fb45d..a17ed48663c8f 100644 --- a/solution/2000-2099/2037.Minimum Number of Moves to Seat Everyone/README_EN.md +++ b/solution/2000-2099/2037.Minimum Number of Moves to Seat Everyone/README_EN.md @@ -39,9 +39,9 @@ tags: Input: seats = [3,1,5], students = [2,7,4] Output: 4 Explanation: The students are moved as follows: -- The first student is moved from from position 2 to position 1 using 1 move. -- The second student is moved from from position 7 to position 5 using 2 moves. -- The third student is moved from from position 4 to position 3 using 1 move. +- The first student is moved from position 2 to position 1 using 1 move. +- The second student is moved from position 7 to position 5 using 2 moves. +- The third student is moved from position 4 to position 3 using 1 move. In total, 1 + 2 + 1 = 4 moves were used. @@ -52,9 +52,9 @@ In total, 1 + 2 + 1 = 4 moves were used. Output: 7 Explanation: The students are moved as follows: - The first student is not moved. -- The second student is moved from from position 3 to position 4 using 1 move. -- The third student is moved from from position 2 to position 5 using 3 moves. -- The fourth student is moved from from position 6 to position 9 using 3 moves. +- The second student is moved from position 3 to position 4 using 1 move. +- The third student is moved from position 2 to position 5 using 3 moves. +- The fourth student is moved from position 6 to position 9 using 3 moves. In total, 0 + 1 + 3 + 3 = 7 moves were used. @@ -65,8 +65,8 @@ In total, 0 + 1 + 3 + 3 = 7 moves were used. Output: 4 Explanation: Note that there are two seats at position 2 and two seats at position 6. The students are moved as follows: -- The first student is moved from from position 1 to position 2 using 1 move. -- The second student is moved from from position 3 to position 6 using 3 moves. +- The first student is moved from position 1 to position 2 using 1 move. +- The second student is moved from position 3 to position 6 using 3 moves. - The third student is not moved. - The fourth student is not moved. In total, 1 + 3 + 0 + 0 = 4 moves were used. diff --git a/solution/2300-2399/2314.The First Day of the Maximum Recorded Degree in Each City/README_EN.md b/solution/2300-2399/2314.The First Day of the Maximum Recorded Degree in Each City/README_EN.md index 082509da7d255..d7f60b6ea4c22 100644 --- a/solution/2300-2399/2314.The First Day of the Maximum Recorded Degree in Each City/README_EN.md +++ b/solution/2300-2399/2314.The First Day of the Maximum Recorded Degree in Each City/README_EN.md @@ -66,7 +66,7 @@ Weather table: +---------+------------+--------+ Explanation: For city 1, the maximum degree was recorded on 2022-07-07 with 24 degrees. -For city 1, the maximum degree was recorded on 2022-08-07 and 2022-08-17 with 37 degrees. We choose the earlier date (2022-08-07). +For city 2, the maximum degree was recorded on 2022-08-07 and 2022-08-17 with 37 degrees. We choose the earlier date (2022-08-07). For city 3, the maximum degree was recorded on 2022-12-07 with -6 degrees. diff --git a/solution/2300-2399/2364.Count Number of Bad Pairs/README.md b/solution/2300-2399/2364.Count Number of Bad Pairs/README.md index fb7ae0f252728..a201630d8b0d2 100644 --- a/solution/2300-2399/2364.Count Number of Bad Pairs/README.md +++ b/solution/2300-2399/2364.Count Number of Bad Pairs/README.md @@ -7,6 +7,8 @@ source: 第 84 场双周赛 Q2 tags: - 数组 - 哈希表 + - 数学 + - 计数 --- diff --git a/solution/2300-2399/2364.Count Number of Bad Pairs/README_EN.md b/solution/2300-2399/2364.Count Number of Bad Pairs/README_EN.md index b2f7b50ebc63c..4f0c61f0b143f 100644 --- a/solution/2300-2399/2364.Count Number of Bad Pairs/README_EN.md +++ b/solution/2300-2399/2364.Count Number of Bad Pairs/README_EN.md @@ -7,6 +7,8 @@ source: Biweekly Contest 84 Q2 tags: - Array - Hash Table + - Math + - Counting --- diff --git a/solution/2700-2799/2751.Robot Collisions/README_EN.md b/solution/2700-2799/2751.Robot Collisions/README_EN.md index d3516d9da0290..86c6c57a553b0 100644 --- a/solution/2700-2799/2751.Robot Collisions/README_EN.md +++ b/solution/2700-2799/2751.Robot Collisions/README_EN.md @@ -29,7 +29,7 @@ tags:

If two robots collide, the robot with lower health is removed from the line, and the health of the other robot decreases by one. The surviving robot continues in the same direction it was going. If both robots have the same health, they are both removed from the line.

-

Your task is to determine the health of the robots that survive the collisions, in the same order that the robots were given, i.e. final heath of robot 1 (if survived), final health of robot 2 (if survived), and so on. If there are no survivors, return an empty array.

+

Your task is to determine the health of the robots that survive the collisions, in the same order that the robots were given, i.e. final health of robot 1 (if survived), final health of robot 2 (if survived), and so on. If there are no survivors, return an empty array.

Return an array containing the health of the remaining robots (in the order they were given in the input), after no further collisions can occur.

diff --git a/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README.md b/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README.md index b1518e39a5b21..a5988bd60cbe9 100644 --- a/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README.md +++ b/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README.md @@ -8,6 +8,7 @@ tags: - 贪心 - 数组 - 数学 + - 二分查找 - 排序 --- diff --git a/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README_EN.md b/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README_EN.md index 844930b3fc80a..91acd5c5a9d83 100644 --- a/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README_EN.md +++ b/solution/2900-2999/2967.Minimum Cost to Make Array Equalindromic/README_EN.md @@ -8,6 +8,7 @@ tags: - Greedy - Array - Math + - Binary Search - Sorting --- diff --git a/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md b/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md index b7bc91dac3183..6ea2ba2e5b9f1 100644 --- a/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md +++ b/solution/3100-3199/3104.Find Longest Self-Contained Substring/README.md @@ -11,7 +11,7 @@ tags: -# [3104. Find Longest Self-Contained Substring 🔒](https://leetcode.cn/problems/find-longest-self-contained-substring) +# [3104. 查找最长的自包含子串 🔒](https://leetcode.cn/problems/find-longest-self-contained-substring) [English Version](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README_EN.md) @@ -19,52 +19,54 @@ tags: -

Given a string s, your task is to find the length of the longest self-contained substring of s.

+

给定字符串 s,你需要找到 s 的 最长自包含 子串 的长度。

-

A substring t of a string s is called self-contained if t != s and for every character in t, it doesn't exist in the rest of s.

+

如果 s 的一个子串 t 满足 t != s 且 t 中的每一个字符在 s 的剩余部分都不存在,则被称为是 自包含 的。

-

Return the length of the longest self-contained substring of s if it exists, otherwise, return -1.

+

如果存在  s 的最长自包含子串,返回它的长度,否则返回 -1。

 

-

Example 1:

+ +

示例 1:

-

Input: s = "abba"

+

输入:s = "abba"

-

Output: 2

+

输出:2

-

Explanation:
-Let's check the substring "bb". You can see that no other "b" is outside of this substring. Hence the answer is 2.

+

解释:
+让我们检查子串 "bb"。你可以发现子串外没有其它 "b"。因此答案为 2。

-

Example 2:

+

示例 2:

-

Input: s = "abab"

+

输入:s = "abab"

-

Output: -1

+

输出:-1

-

Explanation:
-Every substring we choose does not satisfy the described property (there is some character which is inside and outside of that substring). So the answer would be -1.

+

解释:
+我们选择的每一个子串都不满足描述的特点(子串内外包含有一些字母)。所以答案是 -1。

-

Example 3:

+

示例 3:

-

Input: s = "abacd"

+

输入:s = "abacd"

-

Output: 4

+

输出:4

-

Explanation:
-Let's check the substring "abac". There is only one character outside of this substring and that is "d". There is no "d" inside the chosen substring, so it satisfies the condition and the answer is 4.

+

解释:
+让我们检查子串 "abac"。子串之外只有一个字母 "d"。子串内没有 "d",所以它满足条件并且答案为 4。

 

-

Constraints:

+ +

提示:

diff --git a/solution/3100-3199/3109.Find the Index of Permutation/README.md b/solution/3100-3199/3109.Find the Index of Permutation/README.md index 61493ca42d714..c35c47bcdbf81 100644 --- a/solution/3100-3199/3109.Find the Index of Permutation/README.md +++ b/solution/3100-3199/3109.Find the Index of Permutation/README.md @@ -14,7 +14,7 @@ tags: -# [3109. Find the Index of Permutation 🔒](https://leetcode.cn/problems/find-the-index-of-permutation) +# [3109. 查找排列的下标 🔒](https://leetcode.cn/problems/find-the-index-of-permutation) [English Version](/solution/3100-3199/3109.Find%20the%20Index%20of%20Permutation/README_EN.md) @@ -22,49 +22,51 @@ tags: -

Given an array perm of length n which is a permutation of [1, 2, ..., n], return the index of perm in the lexicographically sorted array of all of the permutations of [1, 2, ..., n].

+

给定一个长度为 n 的数组 perm,它是 [1, 2, ..., n] 的一个排列,返回 [1, 2, ..., n] 的所有排列的字典序数组中 perm 的下标。

-

Since the answer may be very large, return it modulo 109 + 7.

+

由于答案可能非常大,返回值对 109 + 7 取模

 

-

Example 1:

+ +

示例 1:

-

Input: perm = [1,2]

+

输入:perm = [1,2]

-

Output: 0

+

输出:0

-

Explanation:

+

解释:

-

There are only two permutations in the following order:

+

按以下顺序只有 2 种排列:

[1,2], [2,1]

-And [1,2] is at index 0.

+并且 [1,2] 在下标 0。

-

Example 2:

+

示例 2:

-

Input: perm = [3,1,2]

+

输入:perm = [3,1,2]

-

Output: 4

+

输出:4

-

Explanation:

+

解释:

-

There are only six permutations in the following order:

+

按以下顺序只有 6 种排列:

[1,2,3], [1,3,2], [2,1,3], [2,3,1], [3,1,2], [3,2,1]

-And [3,1,2] is at index 4.

+并且 [3,1,2] 在下标 4。

 

-

Constraints:

+ +

提示:

diff --git a/solution/3100-3199/3118.Friday Purchase III/README.md b/solution/3100-3199/3118.Friday Purchase III/README.md index e410bb23e0d0e..9f8c0e43f6624 100644 --- a/solution/3100-3199/3118.Friday Purchase III/README.md +++ b/solution/3100-3199/3118.Friday Purchase III/README.md @@ -8,7 +8,7 @@ tags: -# [3118. Friday Purchase III 🔒](https://leetcode.cn/problems/friday-purchase-iii) +# [3118. 发生在周五的交易 III 🔒](https://leetcode.cn/problems/friday-purchase-iii) [English Version](/solution/3100-3199/3118.Friday%20Purchase%20III/README_EN.md) @@ -16,7 +16,7 @@ tags: -

Table: Purchases

+

表:Purchases

 +---------------+------+
@@ -26,12 +26,12 @@ tags:
 | purchase_date | date |
 | amount_spend  | int  |
 +---------------+------+
-(user_id, purchase_date, amount_spend) is the primary key (combination of columns with unique values) for this table.
-purchase_date will range from November 1, 2023, to November 30, 2023, inclusive of both dates.
-Each row contains user_id, purchase_date, and amount_spend.
+(user_id, purchase_date, amount_spend) 是该表的主键(具有唯一值的列)。
+purchase_date 的范围从 2023 年 11 月 1 日到 2023 年 11 月 30 日,并包括这两个日期。
+每一行包含 user_id, purchase_date,和 amount_spend。
 
-

Table: Users

+

表:Users

 +-------------+------+
@@ -40,24 +40,25 @@ Each row contains user_id, purchase_date, and amount_spend.
 | user_id     | int  |
 | membership  | enum |
 +-------------+------+
-user_id is the primary key for this table.
-membership is an ENUM (category) type of ('Standard', 'Premium', 'VIP').
-Each row of this table indicates the user_id, membership type.
+user_id 是这张表的主键。
+membership 是 ('Standard', 'Premium', 'VIP') 的枚举类型。
+这张表的每一行表示 user_id 和会员类型。
 
-

Write a solution to calculate the total spending by Premium and VIP members on each Friday of every week in November 2023.  If there are no purchases on a particular Friday by Premium or VIP members, it should be considered as 0.

+

编写一个解决方案来计算 Premium 和 VIP 会员在 2023 年 11 月 每周的周五 的 总花费。如果某个周五没有 Premium 或 VIP 会员购买,把它当作 0

-

Return the result table ordered by week of the month,  and membership in ascending order.

+

按照每月的周次序 升序 排列结果表,然后以 membership 升序 排序。

-

The result format is in the following example.

+

结果格式如下所示。

 

-

Example:

+ +

示例:

-

Input:

+

输入:

-

Purchases table:

+

Purchases 表:

 +---------+---------------+--------------+
@@ -74,7 +75,7 @@ Each row of this table indicates the user_id, membership type.
 +---------+---------------+--------------+
 
-

Users table:

+

Users 表:

 +---------+------------+
@@ -91,7 +92,7 @@ Each row of this table indicates the user_id, membership type.
 +---------+------------+
 
-

Output:

+

输出:

 +---------------+-------------+--------------+
@@ -108,16 +109,16 @@ Each row of this table indicates the user_id, membership type.
 +---------------+-------------+--------------+
         
-

Explanation:

+

解释:

-

Note: The output table is ordered by week_of_month and membership in ascending order.

+

注意:输出表以 week_of_month 和 membership 升序排序。

diff --git a/solution/3100-3199/3124.Find Longest Calls/README_EN.md b/solution/3100-3199/3124.Find Longest Calls/README_EN.md index 8f9215c557c1f..120fdda606e7b 100644 --- a/solution/3100-3199/3124.Find Longest Calls/README_EN.md +++ b/solution/3100-3199/3124.Find Longest Calls/README_EN.md @@ -97,24 +97,24 @@ Each row of this table contains information about calls, comprising of contact_i +-----------+----------+-------------------+ | first_name| type | duration_formatted| +-----------+----------+-------------------+ -| Michael | incoming | 00:07:00 | -| Jane | incoming | 00:05:00 | -| Emily | incoming | 00:03:00 | | Alice | outgoing | 00:06:00 | | Emily | outgoing | 00:04:40 | | Jane | outgoing | 00:04:00 | +| Michael | incoming | 00:07:00 | +| Jane | incoming | 00:05:00 | +| Emily | incoming | 00:03:00 | +-----------+----------+-------------------+

Explanation:

Note: Output table is sorted by type, duration, and first_name in descending order.

diff --git a/solution/3100-3199/3134.Find the Median of the Uniqueness Array/README.md b/solution/3100-3199/3134.Find the Median of the Uniqueness Array/README.md index 7970ae1d3e7ef..c1db9a58eee8f 100644 --- a/solution/3100-3199/3134.Find the Median of the Uniqueness Array/README.md +++ b/solution/3100-3199/3134.Find the Median of the Uniqueness Array/README.md @@ -21,7 +21,7 @@ tags: -

给你一个整数数组 nums 。数组 nums 唯一性数组 是一个按元素从小到大排序的数组,包含了 nums 的所有非空子数组中不同元素的个数。

+

给你一个整数数组 nums 。数组 nums 唯一性数组 是一个按元素从小到大排序的数组,包含了 nums 的所有非空 子数组 中不同元素的个数。

换句话说,这是由所有 0 <= i <= j < nums.lengthdistinct(nums[i..j]) 组成的递增数组。

diff --git a/solution/3100-3199/3146.Permutation Difference between Two Strings/README.md b/solution/3100-3199/3146.Permutation Difference between Two Strings/README.md index 76d2880164917..cddae11d31b0d 100644 --- a/solution/3100-3199/3146.Permutation Difference between Two Strings/README.md +++ b/solution/3100-3199/3146.Permutation Difference between Two Strings/README.md @@ -44,7 +44,7 @@ tags:
  • "c"s 中的位置与在 t 中的位置之差的绝对值。
  • -

    即,st 的排列差等于 |0 - 1| + |2 - 2| + |1 - 0| = 2

    +

    即,st 的排列差等于 |0 - 1| + |1 - 0| + |2 - 2| = 2

    示例 2:

    diff --git a/solution/3100-3199/3146.Permutation Difference between Two Strings/README_EN.md b/solution/3100-3199/3146.Permutation Difference between Two Strings/README_EN.md index 95ae78b3ca3c3..a0116f56c4cf9 100644 --- a/solution/3100-3199/3146.Permutation Difference between Two Strings/README_EN.md +++ b/solution/3100-3199/3146.Permutation Difference between Two Strings/README_EN.md @@ -43,7 +43,7 @@ tags:
  • The absolute difference between the index of the occurrence of "c" in s and the index of the occurrence of "c" in t.
  • -

    That is, the permutation difference between s and t is equal to |0 - 1| + |2 - 2| + |1 - 0| = 2.

    +

    That is, the permutation difference between s and t is equal to |0 - 1| + |1 - 0| + |2 - 2| = 2.

    Example 2:

    diff --git a/solution/3100-3199/3178.Find the Child Who Has the Ball After K Seconds/README.md b/solution/3100-3199/3178.Find the Child Who Has the Ball After K Seconds/README.md index 99adfd76fec09..8ab09cd3319ff 100644 --- a/solution/3100-3199/3178.Find the Child Who Has the Ball After K Seconds/README.md +++ b/solution/3100-3199/3178.Find the Child Who Has the Ball After K Seconds/README.md @@ -157,6 +157,10 @@ tags:
  • 1 <= k <= 50
  • +

     

    + +

    注意:此问题与 2582. 递枕头 一致。

    + ## 解法 diff --git a/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README.md b/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README.md index 25da724d491c6..319f2f312e85c 100644 --- a/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README.md +++ b/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README.md @@ -2,6 +2,10 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3263.Convert%20Doubly%20Linked%20List%20to%20Array%20I/README.md +tags: + - 数组 + - 链表 + - 双向链表 --- diff --git a/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README_EN.md b/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README_EN.md index 88319b5e7b123..4bd707425088e 100644 --- a/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README_EN.md +++ b/solution/3200-3299/3263.Convert Doubly Linked List to Array I/README_EN.md @@ -2,6 +2,10 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3263.Convert%20Doubly%20Linked%20List%20to%20Array%20I/README_EN.md +tags: + - Array + - Linked List + - Doubly-Linked List --- diff --git a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md index 63f3dfd3d839f..914a955d2916d 100644 --- a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md +++ b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README.md @@ -2,6 +2,11 @@ comments: true difficulty: 简单 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README.md +tags: + - 数组 + - 数学 + - 模拟 + - 堆(优先队列) --- diff --git a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md index bd93fdade75f7..32619fb63aee2 100644 --- a/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md +++ b/solution/3200-3299/3264.Final Array State After K Multiplication Operations I/README_EN.md @@ -2,6 +2,11 @@ comments: true difficulty: Easy edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README_EN.md +tags: + - Array + - Math + - Simulation + - Heap (Priority Queue) --- diff --git a/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md b/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md index e092294652508..d323d0224e1dc 100644 --- a/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md +++ b/solution/3200-3299/3265.Count Almost Equal Pairs I/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 中等 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README.md +tags: + - 数组 + - 哈希表 + - 计数 + - 枚举 + - 排序 --- @@ -66,7 +72,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3265.Co

    解释:

    -

    我们无法通过交换 123 或者 321 中的两个数位得到另一个数。

    +

    我们无法通过交换 123 或者 321 中的两个数位得到另一个数。

     

    diff --git a/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md b/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md index bf19be12d55e6..9889eb8bca69a 100644 --- a/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md +++ b/solution/3200-3299/3265.Count Almost Equal Pairs I/README_EN.md @@ -2,6 +2,12 @@ comments: true difficulty: Medium edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README_EN.md +tags: + - Array + - Hash Table + - Counting + - Enumeration + - Sorting --- @@ -65,7 +71,7 @@ edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3265.Co

    Explanation:

    -

    We cannot swap any two digits of 123 or 231 to reach the other.

    +

    We cannot swap any two digits of 123 or 231 to reach the other.

     

    diff --git a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md index 3c34aba5086af..880dee8e29e51 100644 --- a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md +++ b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README.md @@ -2,6 +2,10 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README.md +tags: + - 数组 + - 模拟 + - 堆(优先队列) --- diff --git a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md index d994bda463e0f..72c85e8af7494 100644 --- a/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md +++ b/solution/3200-3299/3266.Final Array State After K Multiplication Operations II/README_EN.md @@ -2,6 +2,10 @@ comments: true difficulty: Hard edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README_EN.md +tags: + - Array + - Simulation + - Heap (Priority Queue) --- diff --git a/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md b/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md index f9c8bca7706f6..d01441c06554d 100644 --- a/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md +++ b/solution/3200-3299/3267.Count Almost Equal Pairs II/README.md @@ -2,6 +2,12 @@ comments: true difficulty: 困难 edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3267.Count%20Almost%20Equal%20Pairs%20II/README.md +tags: + - 数组 + - 哈希表 + - 计数 + - 枚举 + - 排序 --- diff --git a/solution/3200-3299/3267.Count Almost Equal Pairs II/README_EN.md b/solution/3200-3299/3267.Count Almost Equal Pairs II/README_EN.md index d7e7e304dd3f3..4d02f2f9bda46 100644 --- a/solution/3200-3299/3267.Count Almost Equal Pairs II/README_EN.md +++ b/solution/3200-3299/3267.Count Almost Equal 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/3267.Count%20Almost%20Equal%20Pairs%20II/README_EN.md +tags: + - Array + - Hash Table + - Counting + - Enumeration + - Sorting --- diff --git a/solution/3200-3299/3268.Find Overlapping Shifts II/README.md b/solution/3200-3299/3268.Find Overlapping Shifts II/README.md index 66118275f3916..86cc958268c18 100644 --- a/solution/3200-3299/3268.Find Overlapping Shifts II/README.md +++ b/solution/3200-3299/3268.Find Overlapping Shifts II/README.md @@ -8,7 +8,7 @@ tags: -# [3268. Find Overlapping Shifts II 🔒](https://leetcode.cn/problems/find-overlapping-shifts-ii) +# [3268. 查找重叠的班次 II 🔒](https://leetcode.cn/problems/find-overlapping-shifts-ii) [English Version](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README_EN.md) @@ -16,7 +16,7 @@ tags: -

    Table: EmployeeShifts

    +

    表:EmployeeShifts

     +------------------+----------+
    @@ -26,30 +26,31 @@ tags:
     | start_time       | datetime |
     | end_time         | datetime |
     +------------------+----------+
    -(employee_id, start_time) is the unique key for this table.
    -This table contains information about the shifts worked by employees, including the start time, and end time.
    +(employee_id, start_time) 是此表的唯一主键。
    +这张表包含员工的排班工作,包括特定日期的开始和结束时间。
     
    -

    Write a solution to analyze overlapping shifts for each employee. Two shifts are considered overlapping if they occur on the same date and one shift's end_time is later than another shift's start_time.

    +

    编写一个解决方案来为每个员工分析重叠排班。如果一个排班的 end_time 比另一个排班的 start_time 更晚 则认为两个排班重叠。

    -

    For each employee, calculate the following:

    +

    对于 每个员工,计算如下内容:

      -
    1. The maximum number of shifts that overlap at any given time.
    2. -
    3. The total duration of all overlaps in minutes.
    4. +
    5. 任何 给定时间重叠 最大 班次数。
    6. +
    7. 所有重叠班次的 总持续时间,以分钟为单位。
    -

    Return the result table ordered by employee_id in ascending order.

    +

    返回结果表以 employee_id 升序 排序。

    -

    The query result format is in the following example.

    +

    查询结果格式如下所示。

     

    -

    Example:

    + +

    示例:

    -

    Input:

    +

    输入:

    -

    EmployeeShifts table:

    +

    EmployeeShifts 表:

     +-------------+---------------------+---------------------+
    @@ -64,7 +65,7 @@ This table contains information about the shifts worked by employees, including
     +-------------+---------------------+---------------------+
     
    -

    Output:

    +

    输出:

     +-------------+---------------------------+------------------------+
    @@ -76,26 +77,26 @@ This table contains information about the shifts worked by employees, including
     +-------------+---------------------------+------------------------+
     
    -

    Explanation:

    +

    解释:

    -

    The output table contains the employee_id, the maximum number of simultaneous overlaps, and the total overlap duration in minutes for each employee, ordered by employee_id in ascending order.

    +

    输出表包含 employee_id,同时重叠排班的最大数量,以及每位员工的重叠班次总持续时间(分钟),以 employee_id 升序排序。

    diff --git a/solution/3200-3299/3269.Constructing Two Increasing Arrays/README.md b/solution/3200-3299/3269.Constructing Two Increasing Arrays/README.md new file mode 100644 index 0000000000000..9a00fca5cee30 --- /dev/null +++ b/solution/3200-3299/3269.Constructing Two Increasing Arrays/README.md @@ -0,0 +1,231 @@ +--- +comments: true +difficulty: 困难 +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README.md +--- + + + +# [3269. Constructing Two Increasing Arrays 🔒](https://leetcode.cn/problems/constructing-two-increasing-arrays) + +[English Version](/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README_EN.md) + +## 题目描述 + + + +

    Given 2 integer arrays nums1 and nums2 consisting only of 0 and 1, your task is to calculate the minimum possible largest number in arrays nums1 and nums2, after doing the following.

    + +

    Replace every 0 with an even positive integer and every 1 with an odd positive integer. After replacement, both arrays should be increasing and each integer should be used at most once.

    + +

    Return the minimum possible largest number after applying the changes.

    + +

     

    +

    Example 1:

    + +
    +

    Input: nums1 = [], nums2 = [1,0,1,1]

    + +

    Output: 5

    + +

    Explanation:

    + +

    After replacing, nums1 = [], and nums2 = [1, 2, 3, 5].

    +
    + +

    Example 2:

    + +
    +

    Input: nums1 = [0,1,0,1], nums2 = [1,0,0,1]

    + +

    Output: 9

    + +

    Explanation:

    + +

    One way to replace, having 9 as the largest element is nums1 = [2, 3, 8, 9], and nums2 = [1, 4, 6, 7].

    +
    + +

    Example 3:

    + +
    +

    Input: nums1 = [0,1,0,0,1], nums2 = [0,0,0,1]

    + +

    Output: 13

    + +

    Explanation:

    + +

    One way to replace, having 13 as the largest element is nums1 = [2, 3, 4, 6, 7], and nums2 = [8, 10, 12, 13].

    +
    + +

     

    +

    Constraints:

    + + + + + +## 解法 + + + +### 方法一:动态规划 + +我们定义 $f[i][j]$ 表示数组 $\textit{nums1}$ 的前 $i$ 个元素和数组 $\textit{nums2}$ 的前 $j$ 个元素中,最小的最大值。初始时 $f[i][j] = 0$,答案为 $f[m][n]$,其中 $m$ 和 $n$ 分别是数组 $\textit{nums1}$ 和 $\textit{nums2}$ 的长度。 + +如果 $j = 0$,那么 $f[i][0]$ 的值只能由 $f[i - 1][0]$ 转移得到,转移方程为 $f[i][0] = \textit{nxt}(f[i - 1][0], \textit{nums1}[i - 1])$,其中 $\textit{nxt}(x, y)$ 表示比 $x$ 大且奇偶性与 $y$ 相同的最小整数。 + +如果 $i = 0$,那么 $f[0][j]$ 的值只能由 $f[0][j - 1]$ 转移得到,转移方程为 $f[0][j] = \textit{nxt}(f[0][j - 1], \textit{nums2}[j - 1])$。 + +如果 $i > 0$ 且 $j > 0$,那么 $f[i][j]$ 的值可以由 $f[i - 1][j]$ 和 $f[i][j - 1]$ 转移得到,转移方程为 $f[i][j] = \min(\textit{nxt}(f[i - 1][j], \textit{nums1}[i - 1]), \textit{nxt}(f[i][j - 1], \textit{nums2}[j - 1]))$。 + +最后返回 $f[m][n]$ 即可。 + +时间复杂度 $O(m \times n)$,空间复杂度 $O(m \times n)$。其中 $m$ 和 $n$ 分别是数组 $\textit{nums1}$ 和 $\textit{nums2}$ 的长度。 + + + +#### Python3 + +```python +class Solution: + def minLargest(self, nums1: List[int], nums2: List[int]) -> int: + def nxt(x: int, y: int) -> int: + return x + 1 if (x & 1 ^ y) == 1 else x + 2 + + m, n = len(nums1), len(nums2) + f = [[0] * (n + 1) for _ in range(m + 1)] + for i, x in enumerate(nums1, 1): + f[i][0] = nxt(f[i - 1][0], x) + for j, y in enumerate(nums2, 1): + f[0][j] = nxt(f[0][j - 1], y) + for i, x in enumerate(nums1, 1): + for j, y in enumerate(nums2, 1): + f[i][j] = min(nxt(f[i - 1][j], x), nxt(f[i][j - 1], y)) + return f[m][n] +``` + +#### Java + +```java +class Solution { + public int minLargest(int[] nums1, int[] nums2) { + int m = nums1.length, n = nums2.length; + int[][] f = new int[m + 1][n + 1]; + for (int i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (int j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (int i = 1; i <= m; ++i) { + for (int j = 1; j <= n; ++j) { + int x = nxt(f[i - 1][j], nums1[i - 1]); + int y = nxt(f[i][j - 1], nums2[j - 1]); + f[i][j] = Math.min(x, y); + } + } + return f[m][n]; + } + + private int nxt(int x, int y) { + return (x & 1 ^ y) == 1 ? x + 1 : x + 2; + } +} +``` + +#### C++ + +```cpp +class Solution { +public: + int minLargest(vector& nums1, vector& nums2) { + int m = nums1.size(), n = nums2.size(); + int f[m + 1][n + 1]; + memset(f, 0, sizeof(f)); + auto nxt = [](int x, int y) -> int { + return (x & 1 ^ y) == 1 ? x + 1 : x + 2; + }; + for (int i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (int j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (int i = 1; i <= m; ++i) { + for (int j = 1; j <= n; ++j) { + int x = nxt(f[i - 1][j], nums1[i - 1]); + int y = nxt(f[i][j - 1], nums2[j - 1]); + f[i][j] = min(x, y); + } + } + return f[m][n]; + } +}; +``` + +#### Go + +```go +func minLargest(nums1 []int, nums2 []int) int { + m, n := len(nums1), len(nums2) + f := make([][]int, m+1) + for i := range f { + f[i] = make([]int, n+1) + } + nxt := func(x, y int) int { + if (x&1 ^ y) == 1 { + return x + 1 + } + return x + 2 + } + for i := 1; i <= m; i++ { + f[i][0] = nxt(f[i-1][0], nums1[i-1]) + } + for j := 1; j <= n; j++ { + f[0][j] = nxt(f[0][j-1], nums2[j-1]) + } + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + x := nxt(f[i-1][j], nums1[i-1]) + y := nxt(f[i][j-1], nums2[j-1]) + f[i][j] = min(x, y) + } + } + return f[m][n] +} +``` + +#### TypeScript + +```ts +function minLargest(nums1: number[], nums2: number[]): number { + const m = nums1.length; + const n = nums2.length; + const f: number[][] = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0)); + const nxt = (x: number, y: number): number => { + return (x & 1) ^ y ? x + 1 : x + 2; + }; + for (let i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (let j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (let i = 1; i <= m; ++i) { + for (let j = 1; j <= n; ++j) { + f[i][j] = Math.min(nxt(f[i - 1][j], nums1[i - 1]), nxt(f[i][j - 1], nums2[j - 1])); + } + } + return f[m][n]; +} +``` + + + + + + diff --git a/solution/3200-3299/3269.Constructing Two Increasing Arrays/README_EN.md b/solution/3200-3299/3269.Constructing Two Increasing Arrays/README_EN.md new file mode 100644 index 0000000000000..258d06c133944 --- /dev/null +++ b/solution/3200-3299/3269.Constructing Two Increasing Arrays/README_EN.md @@ -0,0 +1,231 @@ +--- +comments: true +difficulty: Hard +edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README_EN.md +--- + + + +# [3269. Constructing Two Increasing Arrays 🔒](https://leetcode.com/problems/constructing-two-increasing-arrays) + +[中文文档](/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README.md) + +## Description + + + +

    Given 2 integer arrays nums1 and nums2 consisting only of 0 and 1, your task is to calculate the minimum possible largest number in arrays nums1 and nums2, after doing the following.

    + +

    Replace every 0 with an even positive integer and every 1 with an odd positive integer. After replacement, both arrays should be increasing and each integer should be used at most once.

    + +

    Return the minimum possible largest number after applying the changes.

    + +

     

    +

    Example 1:

    + +
    +

    Input: nums1 = [], nums2 = [1,0,1,1]

    + +

    Output: 5

    + +

    Explanation:

    + +

    After replacing, nums1 = [], and nums2 = [1, 2, 3, 5].

    +
    + +

    Example 2:

    + +
    +

    Input: nums1 = [0,1,0,1], nums2 = [1,0,0,1]

    + +

    Output: 9

    + +

    Explanation:

    + +

    One way to replace, having 9 as the largest element is nums1 = [2, 3, 8, 9], and nums2 = [1, 4, 6, 7].

    +
    + +

    Example 3:

    + +
    +

    Input: nums1 = [0,1,0,0,1], nums2 = [0,0,0,1]

    + +

    Output: 13

    + +

    Explanation:

    + +

    One way to replace, having 13 as the largest element is nums1 = [2, 3, 4, 6, 7], and nums2 = [8, 10, 12, 13].

    +
    + +

     

    +

    Constraints:

    + + + + + +## Solutions + + + +### Solution 1: Dynamic Programming + +We define $f[i][j]$ to represent the minimum of the maximum values among the first $i$ elements of array $\textit{nums1}$ and the first $j$ elements of array $\textit{nums2}$. Initially, $f[i][j] = 0$, and the answer is $f[m][n]$, where $m$ and $n$ are the lengths of arrays $\textit{nums1}$ and $\textit{nums2}$, respectively. + +If $j = 0$, then the value of $f[i][0]$ can only be derived from $f[i - 1][0]$, with the transition equation $f[i][0] = \textit{nxt}(f[i - 1][0], \textit{nums1}[i - 1])$, where $\textit{nxt}(x, y)$ represents the smallest integer greater than $x$ that has the same parity as $y$. + +If $i = 0$, then the value of $f[0][j]$ can only be derived from $f[0][j - 1]$, with the transition equation $f[0][j] = \textit{nxt}(f[0][j - 1], \textit{nums2}[j - 1])$. + +If $i > 0$ and $j > 0$, then the value of $f[i][j]$ can be derived from both $f[i - 1][j]$ and $f[i][j - 1]$, with the transition equation $f[i][j] = \min(\textit{nxt}(f[i - 1][j], \textit{nums1}[i - 1]), \textit{nxt}(f[i][j - 1], \textit{nums2}[j - 1]))$. + +Finally, return $f[m][n]$. + +The time complexity is $O(m \times n)$, and the space complexity is $O(m \times n)$. Here, $m$ and $n$ are the lengths of arrays $\textit{nums1}$ and $\textit{nums2}$, respectively. + + + +#### Python3 + +```python +class Solution: + def minLargest(self, nums1: List[int], nums2: List[int]) -> int: + def nxt(x: int, y: int) -> int: + return x + 1 if (x & 1 ^ y) == 1 else x + 2 + + m, n = len(nums1), len(nums2) + f = [[0] * (n + 1) for _ in range(m + 1)] + for i, x in enumerate(nums1, 1): + f[i][0] = nxt(f[i - 1][0], x) + for j, y in enumerate(nums2, 1): + f[0][j] = nxt(f[0][j - 1], y) + for i, x in enumerate(nums1, 1): + for j, y in enumerate(nums2, 1): + f[i][j] = min(nxt(f[i - 1][j], x), nxt(f[i][j - 1], y)) + return f[m][n] +``` + +#### Java + +```java +class Solution { + public int minLargest(int[] nums1, int[] nums2) { + int m = nums1.length, n = nums2.length; + int[][] f = new int[m + 1][n + 1]; + for (int i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (int j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (int i = 1; i <= m; ++i) { + for (int j = 1; j <= n; ++j) { + int x = nxt(f[i - 1][j], nums1[i - 1]); + int y = nxt(f[i][j - 1], nums2[j - 1]); + f[i][j] = Math.min(x, y); + } + } + return f[m][n]; + } + + private int nxt(int x, int y) { + return (x & 1 ^ y) == 1 ? x + 1 : x + 2; + } +} +``` + +#### C++ + +```cpp +class Solution { +public: + int minLargest(vector& nums1, vector& nums2) { + int m = nums1.size(), n = nums2.size(); + int f[m + 1][n + 1]; + memset(f, 0, sizeof(f)); + auto nxt = [](int x, int y) -> int { + return (x & 1 ^ y) == 1 ? x + 1 : x + 2; + }; + for (int i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (int j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (int i = 1; i <= m; ++i) { + for (int j = 1; j <= n; ++j) { + int x = nxt(f[i - 1][j], nums1[i - 1]); + int y = nxt(f[i][j - 1], nums2[j - 1]); + f[i][j] = min(x, y); + } + } + return f[m][n]; + } +}; +``` + +#### Go + +```go +func minLargest(nums1 []int, nums2 []int) int { + m, n := len(nums1), len(nums2) + f := make([][]int, m+1) + for i := range f { + f[i] = make([]int, n+1) + } + nxt := func(x, y int) int { + if (x&1 ^ y) == 1 { + return x + 1 + } + return x + 2 + } + for i := 1; i <= m; i++ { + f[i][0] = nxt(f[i-1][0], nums1[i-1]) + } + for j := 1; j <= n; j++ { + f[0][j] = nxt(f[0][j-1], nums2[j-1]) + } + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + x := nxt(f[i-1][j], nums1[i-1]) + y := nxt(f[i][j-1], nums2[j-1]) + f[i][j] = min(x, y) + } + } + return f[m][n] +} +``` + +#### TypeScript + +```ts +function minLargest(nums1: number[], nums2: number[]): number { + const m = nums1.length; + const n = nums2.length; + const f: number[][] = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0)); + const nxt = (x: number, y: number): number => { + return (x & 1) ^ y ? x + 1 : x + 2; + }; + for (let i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (let j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (let i = 1; i <= m; ++i) { + for (let j = 1; j <= n; ++j) { + f[i][j] = Math.min(nxt(f[i - 1][j], nums1[i - 1]), nxt(f[i][j - 1], nums2[j - 1])); + } + } + return f[m][n]; +} +``` + + + + + + diff --git a/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.cpp b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.cpp new file mode 100644 index 0000000000000..7ceea085f093e --- /dev/null +++ b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.cpp @@ -0,0 +1,25 @@ +class Solution { +public: + int minLargest(vector& nums1, vector& nums2) { + int m = nums1.size(), n = nums2.size(); + int f[m + 1][n + 1]; + memset(f, 0, sizeof(f)); + auto nxt = [](int x, int y) -> int { + return (x & 1 ^ y) == 1 ? x + 1 : x + 2; + }; + for (int i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (int j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (int i = 1; i <= m; ++i) { + for (int j = 1; j <= n; ++j) { + int x = nxt(f[i - 1][j], nums1[i - 1]); + int y = nxt(f[i][j - 1], nums2[j - 1]); + f[i][j] = min(x, y); + } + } + return f[m][n]; + } +}; diff --git a/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.go b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.go new file mode 100644 index 0000000000000..ec324accd6cdf --- /dev/null +++ b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.go @@ -0,0 +1,27 @@ +func minLargest(nums1 []int, nums2 []int) int { + m, n := len(nums1), len(nums2) + f := make([][]int, m+1) + for i := range f { + f[i] = make([]int, n+1) + } + nxt := func(x, y int) int { + if (x&1 ^ y) == 1 { + return x + 1 + } + return x + 2 + } + for i := 1; i <= m; i++ { + f[i][0] = nxt(f[i-1][0], nums1[i-1]) + } + for j := 1; j <= n; j++ { + f[0][j] = nxt(f[0][j-1], nums2[j-1]) + } + for i := 1; i <= m; i++ { + for j := 1; j <= n; j++ { + x := nxt(f[i-1][j], nums1[i-1]) + y := nxt(f[i][j-1], nums2[j-1]) + f[i][j] = min(x, y) + } + } + return f[m][n] +} diff --git a/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.java b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.java new file mode 100644 index 0000000000000..86eb672652b84 --- /dev/null +++ b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.java @@ -0,0 +1,24 @@ +class Solution { + public int minLargest(int[] nums1, int[] nums2) { + int m = nums1.length, n = nums2.length; + int[][] f = new int[m + 1][n + 1]; + for (int i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (int j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (int i = 1; i <= m; ++i) { + for (int j = 1; j <= n; ++j) { + int x = nxt(f[i - 1][j], nums1[i - 1]); + int y = nxt(f[i][j - 1], nums2[j - 1]); + f[i][j] = Math.min(x, y); + } + } + return f[m][n]; + } + + private int nxt(int x, int y) { + return (x & 1 ^ y) == 1 ? x + 1 : x + 2; + } +} diff --git a/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.py b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.py new file mode 100644 index 0000000000000..174e3366b82eb --- /dev/null +++ b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.py @@ -0,0 +1,15 @@ +class Solution: + def minLargest(self, nums1: List[int], nums2: List[int]) -> int: + def nxt(x: int, y: int) -> int: + return x + 1 if (x & 1 ^ y) == 1 else x + 2 + + m, n = len(nums1), len(nums2) + f = [[0] * (n + 1) for _ in range(m + 1)] + for i, x in enumerate(nums1, 1): + f[i][0] = nxt(f[i - 1][0], x) + for j, y in enumerate(nums2, 1): + f[0][j] = nxt(f[0][j - 1], y) + for i, x in enumerate(nums1, 1): + for j, y in enumerate(nums2, 1): + f[i][j] = min(nxt(f[i - 1][j], x), nxt(f[i][j - 1], y)) + return f[m][n] diff --git a/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.ts b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.ts new file mode 100644 index 0000000000000..17b7145b2e859 --- /dev/null +++ b/solution/3200-3299/3269.Constructing Two Increasing Arrays/Solution.ts @@ -0,0 +1,20 @@ +function minLargest(nums1: number[], nums2: number[]): number { + const m = nums1.length; + const n = nums2.length; + const f: number[][] = Array.from({ length: m + 1 }, () => Array(n + 1).fill(0)); + const nxt = (x: number, y: number): number => { + return (x & 1) ^ y ? x + 1 : x + 2; + }; + for (let i = 1; i <= m; ++i) { + f[i][0] = nxt(f[i - 1][0], nums1[i - 1]); + } + for (let j = 1; j <= n; ++j) { + f[0][j] = nxt(f[0][j - 1], nums2[j - 1]); + } + for (let i = 1; i <= m; ++i) { + for (let j = 1; j <= n; ++j) { + f[i][j] = Math.min(nxt(f[i - 1][j], nums1[i - 1]), nxt(f[i][j - 1], nums2[j - 1])); + } + } + return f[m][n]; +} diff --git a/solution/DATABASE_README.md b/solution/DATABASE_README.md index 816039b9e7a0b..383c7b7f434bc 100644 --- a/solution/DATABASE_README.md +++ b/solution/DATABASE_README.md @@ -274,7 +274,7 @@ | 3087 | [查找热门话题标签](/solution/3000-3099/3087.Find%20Trending%20Hashtags/README.md) | `数据库` | 中等 | 🔒 | | 3089 | [查找突发行为](/solution/3000-3099/3089.Find%20Bursty%20Behavior/README.md) | `数据库` | 中等 | 🔒 | | 3103 | [查找热门话题标签 II](/solution/3100-3199/3103.Find%20Trending%20Hashtags%20II/README.md) | `数据库` | 困难 | 🔒 | -| 3118 | [Friday Purchase III](/solution/3100-3199/3118.Friday%20Purchase%20III/README.md) | `数据库` | 中等 | 🔒 | +| 3118 | [发生在周五的交易 III](/solution/3100-3199/3118.Friday%20Purchase%20III/README.md) | `数据库` | 中等 | 🔒 | | 3124 | [查找最长的电话](/solution/3100-3199/3124.Find%20Longest%20Calls/README.md) | `数据库` | 中等 | 🔒 | | 3126 | [服务器利用时间](/solution/3100-3199/3126.Server%20Utilization%20Time/README.md) | `数据库` | 中等 | 🔒 | | 3140 | [连续空余座位 II](/solution/3100-3199/3140.Consecutive%20Available%20Seats%20II/README.md) | `数据库` | 中等 | 🔒 | @@ -292,8 +292,8 @@ | 3236 | [首席执行官下属层级](/solution/3200-3299/3236.CEO%20Subordinate%20Hierarchy/README.md) | `数据库` | 困难 | 🔒 | | 3246 | [英超积分榜排名](/solution/3200-3299/3246.Premier%20League%20Table%20Ranking/README.md) | `数据库` | 简单 | 🔒 | | 3252 | [英超积分榜排名 II](/solution/3200-3299/3252.Premier%20League%20Table%20Ranking%20II/README.md) | `数据库` | 中等 | 🔒 | -| 3262 | [查找重叠的班次](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README.md) | | 中等 | 🔒 | -| 3268 | [Find Overlapping Shifts II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README.md) | | 困难 | 🔒 | +| 3262 | [查找重叠的班次](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README.md) | `数据库` | 中等 | 🔒 | +| 3268 | [查找重叠的班次 II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README.md) | `数据库` | 困难 | 🔒 | ## 版权 diff --git a/solution/DATABASE_README_EN.md b/solution/DATABASE_README_EN.md index c62399917d91c..74fa25d81f661 100644 --- a/solution/DATABASE_README_EN.md +++ b/solution/DATABASE_README_EN.md @@ -290,8 +290,8 @@ Press Control + F(or Command + F on | 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) | `Database` | Medium | 🔒 | -| 3262 | [Find Overlapping Shifts](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README_EN.md) | | Medium | 🔒 | -| 3268 | [Find Overlapping Shifts II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README_EN.md) | | Hard | 🔒 | +| 3262 | [Find Overlapping Shifts](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README_EN.md) | `Database` | Medium | 🔒 | +| 3268 | [Find Overlapping Shifts II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README_EN.md) | `Database` | Hard | 🔒 | ## Copyright diff --git a/solution/README.md b/solution/README.md index 38ab783287067..0dcb14d29365b 100644 --- a/solution/README.md +++ b/solution/README.md @@ -2374,7 +2374,7 @@ | 2361 | [乘坐火车路线的最少费用](/solution/2300-2399/2361.Minimum%20Costs%20Using%20the%20Train%20Line/README.md) | `数组`,`动态规划` | 困难 | 🔒 | | 2362 | [生成发票](/solution/2300-2399/2362.Generate%20the%20Invoice/README.md) | `数据库` | 困难 | 🔒 | | 2363 | [合并相似的物品](/solution/2300-2399/2363.Merge%20Similar%20Items/README.md) | `数组`,`哈希表`,`有序集合`,`排序` | 简单 | 第 84 场双周赛 | -| 2364 | [统计坏数对的数目](/solution/2300-2399/2364.Count%20Number%20of%20Bad%20Pairs/README.md) | `数组`,`哈希表` | 中等 | 第 84 场双周赛 | +| 2364 | [统计坏数对的数目](/solution/2300-2399/2364.Count%20Number%20of%20Bad%20Pairs/README.md) | `数组`,`哈希表`,`数学`,`计数` | 中等 | 第 84 场双周赛 | | 2365 | [任务调度器 II](/solution/2300-2399/2365.Task%20Scheduler%20II/README.md) | `数组`,`哈希表`,`模拟` | 中等 | 第 84 场双周赛 | | 2366 | [将数组排序的最少替换次数](/solution/2300-2399/2366.Minimum%20Replacements%20to%20Sort%20the%20Array/README.md) | `贪心`,`数组`,`数学` | 困难 | 第 84 场双周赛 | | 2367 | [算术三元组的数目](/solution/2300-2399/2367.Number%20of%20Arithmetic%20Triplets/README.md) | `数组`,`哈希表`,`双指针`,`枚举` | 简单 | 第 305 场周赛 | @@ -2977,7 +2977,7 @@ | 2964 | [可被整除的三元组数量](/solution/2900-2999/2964.Number%20of%20Divisible%20Triplet%20Sums/README.md) | `数组`,`哈希表` | 中等 | 🔒 | | 2965 | [找出缺失和重复的数字](/solution/2900-2999/2965.Find%20Missing%20and%20Repeated%20Values/README.md) | `数组`,`哈希表`,`数学`,`矩阵` | 简单 | 第 376 场周赛 | | 2966 | [划分数组并满足最大差限制](/solution/2900-2999/2966.Divide%20Array%20Into%20Arrays%20With%20Max%20Difference/README.md) | `贪心`,`数组`,`排序` | 中等 | 第 376 场周赛 | -| 2967 | [使数组成为等数数组的最小代价](/solution/2900-2999/2967.Minimum%20Cost%20to%20Make%20Array%20Equalindromic/README.md) | `贪心`,`数组`,`数学`,`排序` | 中等 | 第 376 场周赛 | +| 2967 | [使数组成为等数数组的最小代价](/solution/2900-2999/2967.Minimum%20Cost%20to%20Make%20Array%20Equalindromic/README.md) | `贪心`,`数组`,`数学`,`二分查找`,`排序` | 中等 | 第 376 场周赛 | | 2968 | [执行操作使频率分数最大](/solution/2900-2999/2968.Apply%20Operations%20to%20Maximize%20Frequency%20Score/README.md) | `数组`,`二分查找`,`前缀和`,`排序`,`滑动窗口` | 困难 | 第 376 场周赛 | | 2969 | [购买水果需要的最少金币数 II](/solution/2900-2999/2969.Minimum%20Number%20of%20Coins%20for%20Fruits%20II/README.md) | `队列`,`数组`,`动态规划`,`单调队列`,`堆(优先队列)` | 困难 | 🔒 | | 2970 | [统计移除递增子数组的数目 I](/solution/2900-2999/2970.Count%20the%20Number%20of%20Incremovable%20Subarrays%20I/README.md) | `数组`,`双指针`,`二分查找`,`枚举` | 简单 | 第 120 场双周赛 | @@ -3114,12 +3114,12 @@ | 3101 | [交替子数组计数](/solution/3100-3199/3101.Count%20Alternating%20Subarrays/README.md) | `数组`,`数学` | 中等 | 第 391 场周赛 | | 3102 | [最小化曼哈顿距离](/solution/3100-3199/3102.Minimize%20Manhattan%20Distances/README.md) | `几何`,`数组`,`数学`,`有序集合`,`排序` | 困难 | 第 391 场周赛 | | 3103 | [查找热门话题标签 II](/solution/3100-3199/3103.Find%20Trending%20Hashtags%20II/README.md) | `数据库` | 困难 | 🔒 | -| 3104 | [Find Longest Self-Contained Substring](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README.md) | `哈希表`,`字符串`,`二分查找`,`前缀和` | 困难 | 🔒 | +| 3104 | [查找最长的自包含子串](/solution/3100-3199/3104.Find%20Longest%20Self-Contained%20Substring/README.md) | `哈希表`,`字符串`,`二分查找`,`前缀和` | 困难 | 🔒 | | 3105 | [最长的严格递增或递减子数组](/solution/3100-3199/3105.Longest%20Strictly%20Increasing%20or%20Strictly%20Decreasing%20Subarray/README.md) | `数组` | 简单 | 第 392 场周赛 | | 3106 | [满足距离约束且字典序最小的字符串](/solution/3100-3199/3106.Lexicographically%20Smallest%20String%20After%20Operations%20With%20Constraint/README.md) | `贪心`,`字符串` | 中等 | 第 392 场周赛 | | 3107 | [使数组中位数等于 K 的最少操作数](/solution/3100-3199/3107.Minimum%20Operations%20to%20Make%20Median%20of%20Array%20Equal%20to%20K/README.md) | `贪心`,`数组`,`排序` | 中等 | 第 392 场周赛 | | 3108 | [带权图里旅途的最小代价](/solution/3100-3199/3108.Minimum%20Cost%20Walk%20in%20Weighted%20Graph/README.md) | `位运算`,`并查集`,`图`,`数组` | 困难 | 第 392 场周赛 | -| 3109 | [Find the Index of Permutation](/solution/3100-3199/3109.Find%20the%20Index%20of%20Permutation/README.md) | `树状数组`,`线段树`,`数组`,`二分查找`,`分治`,`有序集合`,`归并排序` | 中等 | 🔒 | +| 3109 | [查找排列的下标](/solution/3100-3199/3109.Find%20the%20Index%20of%20Permutation/README.md) | `树状数组`,`线段树`,`数组`,`二分查找`,`分治`,`有序集合`,`归并排序` | 中等 | 🔒 | | 3110 | [字符串的分数](/solution/3100-3199/3110.Score%20of%20a%20String/README.md) | `字符串` | 简单 | 第 128 场双周赛 | | 3111 | [覆盖所有点的最少矩形数目](/solution/3100-3199/3111.Minimum%20Rectangles%20to%20Cover%20Points/README.md) | `贪心`,`数组`,`排序` | 中等 | 第 128 场双周赛 | | 3112 | [访问消失节点的最少时间](/solution/3100-3199/3112.Minimum%20Time%20to%20Visit%20Disappearing%20Nodes/README.md) | `图`,`数组`,`最短路`,`堆(优先队列)` | 中等 | 第 128 场双周赛 | @@ -3128,7 +3128,7 @@ | 3115 | [质数的最大距离](/solution/3100-3199/3115.Maximum%20Prime%20Difference/README.md) | `数组`,`数学`,`数论` | 中等 | 第 393 场周赛 | | 3116 | [单面值组合的第 K 小金额](/solution/3100-3199/3116.Kth%20Smallest%20Amount%20With%20Single%20Denomination%20Combination/README.md) | `位运算`,`数组`,`数学`,`二分查找`,`组合数学`,`数论` | 困难 | 第 393 场周赛 | | 3117 | [划分数组得到最小的值之和](/solution/3100-3199/3117.Minimum%20Sum%20of%20Values%20by%20Dividing%20Array/README.md) | `位运算`,`线段树`,`队列`,`数组`,`二分查找`,`动态规划` | 困难 | 第 393 场周赛 | -| 3118 | [Friday Purchase III](/solution/3100-3199/3118.Friday%20Purchase%20III/README.md) | `数据库` | 中等 | 🔒 | +| 3118 | [发生在周五的交易 III](/solution/3100-3199/3118.Friday%20Purchase%20III/README.md) | `数据库` | 中等 | 🔒 | | 3119 | [最大数量的可修复坑洼](/solution/3100-3199/3119.Maximum%20Number%20of%20Potholes%20That%20Can%20Be%20Fixed/README.md) | `贪心`,`字符串`,`排序` | 中等 | 🔒 | | 3120 | [统计特殊字母的数量 I](/solution/3100-3199/3120.Count%20the%20Number%20of%20Special%20Characters%20I/README.md) | `哈希表`,`字符串` | 简单 | 第 394 场周赛 | | 3121 | [统计特殊字母的数量 II](/solution/3100-3199/3121.Count%20the%20Number%20of%20Special%20Characters%20II/README.md) | `哈希表`,`字符串` | 中等 | 第 394 场周赛 | @@ -3272,13 +3272,14 @@ | 3259 | [超级饮料的最大强化能量](/solution/3200-3299/3259.Maximum%20Energy%20Boost%20From%20Two%20Drinks/README.md) | `数组`,`动态规划` | 中等 | 第 411 场周赛 | | 3260 | [找出最大的 N 位 K 回文数](/solution/3200-3299/3260.Find%20the%20Largest%20Palindrome%20Divisible%20by%20K/README.md) | `贪心`,`数学`,`字符串`,`动态规划`,`数论` | 困难 | 第 411 场周赛 | | 3261 | [统计满足 K 约束的子字符串数量 II](/solution/3200-3299/3261.Count%20Substrings%20That%20Satisfy%20K-Constraint%20II/README.md) | `数组`,`字符串`,`二分查找`,`前缀和`,`滑动窗口` | 困难 | 第 411 场周赛 | -| 3262 | [查找重叠的班次](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README.md) | | 中等 | 🔒 | -| 3263 | [将双链表转换为数组 I](/solution/3200-3299/3263.Convert%20Doubly%20Linked%20List%20to%20Array%20I/README.md) | | 简单 | 🔒 | -| 3264 | [K 次乘运算后的最终数组 I](/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README.md) | | 简单 | 第 412 场周赛 | -| 3265 | [统计近似相等数对 I](/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README.md) | | 中等 | 第 412 场周赛 | -| 3266 | [K 次乘运算后的最终数组 II](/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README.md) | | 困难 | 第 412 场周赛 | -| 3267 | [统计近似相等数对 II](/solution/3200-3299/3267.Count%20Almost%20Equal%20Pairs%20II/README.md) | | 困难 | 第 412 场周赛 | -| 3268 | [Find Overlapping Shifts II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README.md) | | 困难 | 🔒 | +| 3262 | [查找重叠的班次](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README.md) | `数据库` | 中等 | 🔒 | +| 3263 | [将双链表转换为数组 I](/solution/3200-3299/3263.Convert%20Doubly%20Linked%20List%20to%20Array%20I/README.md) | `数组`,`链表`,`双向链表` | 简单 | 🔒 | +| 3264 | [K 次乘运算后的最终数组 I](/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README.md) | `数组`,`数学`,`模拟`,`堆(优先队列)` | 简单 | 第 412 场周赛 | +| 3265 | [统计近似相等数对 I](/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README.md) | `数组`,`哈希表`,`计数`,`枚举`,`排序` | 中等 | 第 412 场周赛 | +| 3266 | [K 次乘运算后的最终数组 II](/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README.md) | `数组`,`模拟`,`堆(优先队列)` | 困难 | 第 412 场周赛 | +| 3267 | [统计近似相等数对 II](/solution/3200-3299/3267.Count%20Almost%20Equal%20Pairs%20II/README.md) | `数组`,`哈希表`,`计数`,`枚举`,`排序` | 困难 | 第 412 场周赛 | +| 3268 | [查找重叠的班次 II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README.md) | `数据库` | 困难 | 🔒 | +| 3269 | [Constructing Two Increasing Arrays](/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README.md) | | 困难 | 🔒 | ## 版权 diff --git a/solution/README_EN.md b/solution/README_EN.md index a9f6dbcb4f6b9..b3d8b65651bd7 100644 --- a/solution/README_EN.md +++ b/solution/README_EN.md @@ -2372,7 +2372,7 @@ Press Control + F(or Command + F on | 2361 | [Minimum Costs Using the Train Line](/solution/2300-2399/2361.Minimum%20Costs%20Using%20the%20Train%20Line/README_EN.md) | `Array`,`Dynamic Programming` | Hard | 🔒 | | 2362 | [Generate the Invoice](/solution/2300-2399/2362.Generate%20the%20Invoice/README_EN.md) | `Database` | Hard | 🔒 | | 2363 | [Merge Similar Items](/solution/2300-2399/2363.Merge%20Similar%20Items/README_EN.md) | `Array`,`Hash Table`,`Ordered Set`,`Sorting` | Easy | Biweekly Contest 84 | -| 2364 | [Count Number of Bad Pairs](/solution/2300-2399/2364.Count%20Number%20of%20Bad%20Pairs/README_EN.md) | `Array`,`Hash Table` | Medium | Biweekly Contest 84 | +| 2364 | [Count Number of Bad Pairs](/solution/2300-2399/2364.Count%20Number%20of%20Bad%20Pairs/README_EN.md) | `Array`,`Hash Table`,`Math`,`Counting` | Medium | Biweekly Contest 84 | | 2365 | [Task Scheduler II](/solution/2300-2399/2365.Task%20Scheduler%20II/README_EN.md) | `Array`,`Hash Table`,`Simulation` | Medium | Biweekly Contest 84 | | 2366 | [Minimum Replacements to Sort the Array](/solution/2300-2399/2366.Minimum%20Replacements%20to%20Sort%20the%20Array/README_EN.md) | `Greedy`,`Array`,`Math` | Hard | Biweekly Contest 84 | | 2367 | [Number of Arithmetic Triplets](/solution/2300-2399/2367.Number%20of%20Arithmetic%20Triplets/README_EN.md) | `Array`,`Hash Table`,`Two Pointers`,`Enumeration` | Easy | Weekly Contest 305 | @@ -2975,7 +2975,7 @@ Press Control + F(or Command + F on | 2964 | [Number of Divisible Triplet Sums](/solution/2900-2999/2964.Number%20of%20Divisible%20Triplet%20Sums/README_EN.md) | `Array`,`Hash Table` | Medium | 🔒 | | 2965 | [Find Missing and Repeated Values](/solution/2900-2999/2965.Find%20Missing%20and%20Repeated%20Values/README_EN.md) | `Array`,`Hash Table`,`Math`,`Matrix` | Easy | Weekly Contest 376 | | 2966 | [Divide Array Into Arrays With Max Difference](/solution/2900-2999/2966.Divide%20Array%20Into%20Arrays%20With%20Max%20Difference/README_EN.md) | `Greedy`,`Array`,`Sorting` | Medium | Weekly Contest 376 | -| 2967 | [Minimum Cost to Make Array Equalindromic](/solution/2900-2999/2967.Minimum%20Cost%20to%20Make%20Array%20Equalindromic/README_EN.md) | `Greedy`,`Array`,`Math`,`Sorting` | Medium | Weekly Contest 376 | +| 2967 | [Minimum Cost to Make Array Equalindromic](/solution/2900-2999/2967.Minimum%20Cost%20to%20Make%20Array%20Equalindromic/README_EN.md) | `Greedy`,`Array`,`Math`,`Binary Search`,`Sorting` | Medium | Weekly Contest 376 | | 2968 | [Apply Operations to Maximize Frequency Score](/solution/2900-2999/2968.Apply%20Operations%20to%20Maximize%20Frequency%20Score/README_EN.md) | `Array`,`Binary Search`,`Prefix Sum`,`Sorting`,`Sliding Window` | Hard | Weekly Contest 376 | | 2969 | [Minimum Number of Coins for Fruits II](/solution/2900-2999/2969.Minimum%20Number%20of%20Coins%20for%20Fruits%20II/README_EN.md) | `Queue`,`Array`,`Dynamic Programming`,`Monotonic Queue`,`Heap (Priority Queue)` | Hard | 🔒 | | 2970 | [Count the Number of Incremovable Subarrays I](/solution/2900-2999/2970.Count%20the%20Number%20of%20Incremovable%20Subarrays%20I/README_EN.md) | `Array`,`Two Pointers`,`Binary Search`,`Enumeration` | Easy | Biweekly Contest 120 | @@ -3270,13 +3270,14 @@ Press Control + F(or Command + F on | 3259 | [Maximum Energy Boost From Two Drinks](/solution/3200-3299/3259.Maximum%20Energy%20Boost%20From%20Two%20Drinks/README_EN.md) | `Array`,`Dynamic Programming` | Medium | Weekly Contest 411 | | 3260 | [Find the Largest Palindrome Divisible by K](/solution/3200-3299/3260.Find%20the%20Largest%20Palindrome%20Divisible%20by%20K/README_EN.md) | `Greedy`,`Math`,`String`,`Dynamic Programming`,`Number Theory` | Hard | Weekly Contest 411 | | 3261 | [Count Substrings That Satisfy K-Constraint II](/solution/3200-3299/3261.Count%20Substrings%20That%20Satisfy%20K-Constraint%20II/README_EN.md) | `Array`,`String`,`Binary Search`,`Prefix Sum`,`Sliding Window` | Hard | Weekly Contest 411 | -| 3262 | [Find Overlapping Shifts](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README_EN.md) | | Medium | 🔒 | -| 3263 | [Convert Doubly Linked List to Array I](/solution/3200-3299/3263.Convert%20Doubly%20Linked%20List%20to%20Array%20I/README_EN.md) | | Easy | 🔒 | -| 3264 | [Final Array State After K Multiplication Operations I](/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README_EN.md) | | Easy | Weekly Contest 412 | -| 3265 | [Count Almost Equal Pairs I](/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README_EN.md) | | Medium | Weekly Contest 412 | -| 3266 | [Final Array State After K Multiplication Operations II](/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README_EN.md) | | Hard | Weekly Contest 412 | -| 3267 | [Count Almost Equal Pairs II](/solution/3200-3299/3267.Count%20Almost%20Equal%20Pairs%20II/README_EN.md) | | Hard | Weekly Contest 412 | -| 3268 | [Find Overlapping Shifts II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README_EN.md) | | Hard | 🔒 | +| 3262 | [Find Overlapping Shifts](/solution/3200-3299/3262.Find%20Overlapping%20Shifts/README_EN.md) | `Database` | Medium | 🔒 | +| 3263 | [Convert Doubly Linked List to Array I](/solution/3200-3299/3263.Convert%20Doubly%20Linked%20List%20to%20Array%20I/README_EN.md) | `Array`,`Linked List`,`Doubly-Linked List` | Easy | 🔒 | +| 3264 | [Final Array State After K Multiplication Operations I](/solution/3200-3299/3264.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20I/README_EN.md) | `Array`,`Math`,`Simulation`,`Heap (Priority Queue)` | Easy | Weekly Contest 412 | +| 3265 | [Count Almost Equal Pairs I](/solution/3200-3299/3265.Count%20Almost%20Equal%20Pairs%20I/README_EN.md) | `Array`,`Hash Table`,`Counting`,`Enumeration`,`Sorting` | Medium | Weekly Contest 412 | +| 3266 | [Final Array State After K Multiplication Operations II](/solution/3200-3299/3266.Final%20Array%20State%20After%20K%20Multiplication%20Operations%20II/README_EN.md) | `Array`,`Simulation`,`Heap (Priority Queue)` | Hard | Weekly Contest 412 | +| 3267 | [Count Almost Equal Pairs II](/solution/3200-3299/3267.Count%20Almost%20Equal%20Pairs%20II/README_EN.md) | `Array`,`Hash Table`,`Counting`,`Enumeration`,`Sorting` | Hard | Weekly Contest 412 | +| 3268 | [Find Overlapping Shifts II](/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README_EN.md) | `Database` | Hard | 🔒 | +| 3269 | [Constructing Two Increasing Arrays](/solution/3200-3299/3269.Constructing%20Two%20Increasing%20Arrays/README_EN.md) | | Hard | 🔒 | ## Copyright