diff --git a/.github/workflows/sync.yml b/.github/workflows/sync.yml new file mode 100644 index 0000000000000..4ba27fe009ff3 --- /dev/null +++ b/.github/workflows/sync.yml @@ -0,0 +1,26 @@ +name: Sync + +on: + push: + branches: [ main ] + +jobs: + sync: + runs-on: ubuntu-latest + if: github.repository == 'doocs/leetcode' + steps: + - name: Sync to gitee.com + uses: wearerequired/git-mirror-action@master + env: + SSH_PRIVATE_KEY: ${{ secrets.RSA_PRIVATE_KEY }} + with: + source-repo: git@github.com:doocs/leetcode.git + destination-repo: git@gitee.com:Doocs/leetcode.git + + - name: Build Gitee Pages + uses: yanglbme/gitee-pages-action@main + with: + gitee-username: yanglbme + gitee-password: ${{ secrets.GITEE_PASSWORD }} + gitee-repo: doocs/leetcode + branch: main \ No newline at end of file diff --git a/solution/2800-2899/2877.Create a DataFrame from List/README.md b/solution/2800-2899/2877.Create a DataFrame from List/README.md index 07ea116074b6d..613e740a9d9ea 100644 --- a/solution/2800-2899/2877.Create a DataFrame from List/README.md +++ b/solution/2800-2899/2877.Create a DataFrame from List/README.md @@ -1,4 +1,4 @@ -# [2877. Create a DataFrame from List](https://leetcode.cn/problems/create-a-dataframe-from-list) +# [2877. 从表中创建 DataFrame](https://leetcode.cn/problems/create-a-dataframe-from-list) [English Version](/solution/2800-2899/2877.Create%20a%20DataFrame%20from%20List/README_EN.md) @@ -6,17 +6,18 @@ -
Write a solution to create a DataFrame from a 2D list called student_data
. This 2D list contains the IDs and ages of some students.
编写一个解决方案,从名为 student_data
的二维列表 创建 一个 DataFrame 。这个二维列表包含一些学生的 ID 和年龄信息。
The DataFrame should have two columns, student_id
and age
, and be in the same order as the original 2D list.
DataFrame 应该有两列, student_id
和 age
,并且与原始二维列表的顺序相同。
The result format is in the following example.
+返回结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: student_data:## 解法 diff --git a/solution/2800-2899/2881.Create a New Column/README.md b/solution/2800-2899/2881.Create a New Column/README.md index 5cfda03c8e079..f821932e9de3c 100644 --- a/solution/2800-2899/2881.Create a New Column/README.md +++ b/solution/2800-2899/2881.Create a New Column/README.md @@ -1,4 +1,4 @@ -# [2881. Create a New Column](https://leetcode.cn/problems/create-a-new-column) +# [2881. 创建新列](https://leetcode.cn/problems/create-a-new-column) [English Version](/solution/2800-2899/2881.Create%20a%20New%20Column/README_EN.md) @@ -16,17 +16,18 @@ DataFrame[ [1, 15], @@ -24,7 +25,7 @@ [3, 11], [4, 20] ]
-Output: +输出: +------------+-----+ | student_id | age | +------------+-----+ @@ -33,8 +34,8 @@ | 3 | 11 | | 4 | 20 | +------------+-----+ -Explanation: -A DataFrame was created on top of student_data, with two columns namedstudent_id
andage
. +解释: +在 student_data 上创建了一个 DataFrame,包含 student_id 和 age 两列。
employees
+-------------+--------+
-A company plans to provide its employees with a bonus.
+一家公司计划为员工提供奖金。
-Write a solution to create a new column name bonus
that contains the doubled values of the salary
column.
编写一个解决方案,创建一个名为 bonus
的新列,其中包含 salary
值的 两倍。
The result format is in the following example.
+返回结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: DataFrame employees +---------+--------+ | name | salary | @@ -38,7 +39,7 @@ DataFrame employees | Finn | 74576 | | Thomas | 24433 | +---------+--------+ -Output: +输出: +---------+--------+--------+ | name | salary | bonus | +---------+--------+--------+ @@ -49,8 +50,8 @@ DataFrame employees | Finn | 74576 | 149152 | | Thomas | 24433 | 48866 | +---------+--------+--------+ -Explanation: -A new column bonus is created by doubling the value in the column salary.+解释: +通过将salary列中的值加倍创建了一个新的bonus列。 ## 解法 diff --git a/solution/2800-2899/2882.Drop Duplicate Rows/README.md b/solution/2800-2899/2882.Drop Duplicate Rows/README.md index d814b83dd967d..31449ae09a621 100644 --- a/solution/2800-2899/2882.Drop Duplicate Rows/README.md +++ b/solution/2800-2899/2882.Drop Duplicate Rows/README.md @@ -1,4 +1,4 @@ -# [2882. Drop Duplicate Rows](https://leetcode.cn/problems/drop-duplicate-rows) +# [2882. 删去重复的行](https://leetcode.cn/problems/drop-duplicate-rows) [English Version](/solution/2800-2899/2882.Drop%20Duplicate%20Rows/README_EN.md) @@ -17,16 +17,18 @@ DataFrame customers +-------------+--------+ -
There are some duplicate rows in the DataFrame based on the email
column.
在 DataFrame 中基于 email
列存在一些重复行。
Write a solution to remove these duplicate rows and keep only the first occurrence.
+编写一个解决方案,删除这些重复行,仅保留第一次出现的行。
-The result format is in the following example.
+返回结果格式如下例所示。
+ +
示例 1:
+-Example 1: -Input: +输入: +-------------+---------+---------------------+ | customer_id | name | email | +-------------+---------+---------------------+ @@ -37,7 +39,7 @@ DataFrame customers | 5 | Finn | john@example.com | | 6 | Violet | alice@example.com | +-------------+---------+---------------------+ -Output: +输出: +-------------+---------+---------------------+ | customer_id | name | email | +-------------+---------+---------------------+ @@ -47,8 +49,8 @@ DataFrame customers | 4 | Alice | john@example.com | | 6 | Violet | alice@example.com | +-------------+---------+---------------------+ -Explanation: -Alic (customer_id = 4) and Finn (customer_id = 5) both use john@example.com, so only the first occurrence of this email is retained. +解释: +Alice (customer_id = 4) 和 Finn (customer_id = 5) 都使用 john@example.com,因此只保留该邮箱地址的第一次出现。## 解法 diff --git a/solution/2800-2899/2883.Drop Missing Data/README.md b/solution/2800-2899/2883.Drop Missing Data/README.md index d72fe70296c77..c8e58e06cb506 100644 --- a/solution/2800-2899/2883.Drop Missing Data/README.md +++ b/solution/2800-2899/2883.Drop Missing Data/README.md @@ -1,4 +1,4 @@ -# [2883. Drop Missing Data](https://leetcode.cn/problems/drop-missing-data) +# [2883. 删去丢失的数据](https://leetcode.cn/problems/drop-missing-data) [English Version](/solution/2800-2899/2883.Drop%20Missing%20Data/README_EN.md) @@ -17,17 +17,18 @@ DataFrame students +-------------+--------+ -
There are some rows having missing values in the name
column.
在 name
列里有一些具有缺失值的行。
Write a solution to remove the rows with missing values.
+编写一个解决方案,删除具有缺失值的行。
-The result format is in the following example.
+返回结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: +------------+-------+-----+ | student_id | name | age | +------------+-------+-----+ @@ -36,15 +37,15 @@ DataFrame students | 779 | None | 20 | | 849 | None | 14 | +------------+-------+-----+ -Output: +输出: +------------+-------+-----+ | student_id | name | age | +------------+-------+-----+ | 32 | Piper | 5 | | 217 | Grace | 19 | +------------+-------+-----+ -Explanation: -Students with ids 779 and 849 have empty values in the name column, so they will be removed.+解释: +学号为 779 和 849 的学生所在行在 name 列中有空值,因此它们将被删除。 ## 解法 diff --git a/solution/2800-2899/2884.Modify Columns/README.md b/solution/2800-2899/2884.Modify Columns/README.md index c99f99b1c29d6..9c1016262c3a6 100644 --- a/solution/2800-2899/2884.Modify Columns/README.md +++ b/solution/2800-2899/2884.Modify Columns/README.md @@ -1,4 +1,4 @@ -# [2884. Modify Columns](https://leetcode.cn/problems/modify-columns) +# [2884. 修改列](https://leetcode.cn/problems/modify-columns) [English Version](/solution/2800-2899/2884.Modify%20Columns/README_EN.md) @@ -16,17 +16,18 @@ DataFrame
employees
+-------------+--------+
-A company intends to give its employees a pay rise.
+一家公司决定增加员工的薪水。
-Write a solution to modify the salary
column by multiplying each salary by 2.
编写一个解决方案,将每个员工的薪水乘以2来 修改 salary
列。
The result format is in the following example.
+返回结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: DataFrame employees +---------+--------+ | name | salary | @@ -36,7 +37,7 @@ DataFrame+解释: +每个人的薪水都被加倍。 ## 解法 diff --git a/solution/2800-2899/2885.Rename Columns/README.md b/solution/2800-2899/2885.Rename Columns/README.md index b286bba85f5c7..5ae557f2c18b7 100644 --- a/solution/2800-2899/2885.Rename Columns/README.md +++ b/solution/2800-2899/2885.Rename Columns/README.md @@ -1,4 +1,4 @@ -# [2885. Rename Columns](https://leetcode.cn/problems/rename-columns) +# [2885. 重命名列](https://leetcode.cn/problems/rename-columns) [English Version](/solution/2800-2899/2885.Rename%20Columns/README_EN.md) @@ -18,21 +18,23 @@ DataFrameemployees
| Mia | 62509 | | Ulysses | 54866 | +---------+--------+ -Output: +输出: +---------+--------+ | name | salary | +---------+--------+ @@ -45,8 +46,8 @@ DataFrameemployees
| Mia | 125018 | | Ulysses | 109732 | +---------+--------+ -Explanation: -Every salary has been doubled.
students
+-------------+--------+
-Write a solution to rename the columns as follows:
+编写一个解决方案,按以下方式重命名列:
id
to student_id
first
to first_name
last
to last_name
age
to age_in_years
id
重命名为 student_id
first
重命名为 first_name
last
重命名为 last_name
age
重命名为 age_in_years
The result format is in the following example.
+返回结果格式如下示例所示。
+ +
示例 1:
+-Example 1: -Input: +输入: +----+---------+----------+-----+ | id | first | last | age | +----+---------+----------+-----+ @@ -42,7 +44,7 @@ DataFrame+解释: +列名已相应更换。 ## 解法 diff --git a/solution/2800-2899/2886.Change Data Type/README.md b/solution/2800-2899/2886.Change Data Type/README.md index fe1df64984ed8..04590adcbe6a2 100644 --- a/solution/2800-2899/2886.Change Data Type/README.md +++ b/solution/2800-2899/2886.Change Data Type/README.md @@ -1,4 +1,4 @@ -# [2886. Change Data Type](https://leetcode.cn/problems/change-data-type) +# [2886. 改变数据类型](https://leetcode.cn/problems/change-data-type) [English Version](/solution/2800-2899/2886.Change%20Data%20Type/README_EN.md) @@ -18,16 +18,18 @@ DataFramestudents
| 4 | Georgia | Thompson | 18 | | 5 | Thomas | Moore | 10 | +----+---------+----------+-----+ -Output: +输出: +------------+------------+-----------+--------------+ | student_id | first_name | last_name | age_in_years | +------------+------------+-----------+--------------+ @@ -52,8 +54,8 @@ DataFramestudents
| 4 | Georgia | Thompson | 18 | | 5 | Thomas | Moore | 10 | +------------+------------+-----------+--------------+ -Explanation: -The column names are changed accordingly.
students
+-------------+--------+
-Write a solution to correct the errors:
+编写一个解决方案来纠正以下错误:
-The grade
column is stored as floats, convert it to integers.
grade
列被存储为浮点数,将它转换为整数。
The result format is in the following example.
+返回结果格式如下示例所示。
+ +
示例 1:
+
-Example 1:
-Input:
+输入:
DataFrame students:
+------------+------+-----+-------+
| student_id | name | age | grade |
@@ -35,15 +37,15 @@ DataFrame students
| 1 | Ava | 6 | 73.0 |
| 2 | Kate | 15 | 87.0 |
+------------+------+-----+-------+
-Output:
+输出:
+------------+------+-----+-------+
| student_id | name | age | grade |
+------------+------+-----+-------+
| 1 | Ava | 6 | 73 |
| 2 | Kate | 15 | 87 |
+------------+------+-----+-------+
-Explanation:
-The data types of the column grade is converted to int.
+解释:
+grade 列的数据类型已转换为整数。
## 解法
diff --git a/solution/2800-2899/2887.Fill Missing Data/README.md b/solution/2800-2899/2887.Fill Missing Data/README.md
index 61ef8f6ca9d6b..a7b8208a984ee 100644
--- a/solution/2800-2899/2887.Fill Missing Data/README.md
+++ b/solution/2800-2899/2887.Fill Missing Data/README.md
@@ -1,4 +1,4 @@
-# [2887. Fill Missing Data](https://leetcode.cn/problems/fill-missing-data)
+# [2887. 填充缺失值](https://leetcode.cn/problems/fill-missing-data)
[English Version](/solution/2800-2899/2887.Fill%20Missing%20Data/README_EN.md)
@@ -17,14 +17,16 @@ DataFrame products
+-------------+--------+
-Write a solution to fill in the missing value as 0
in the quantity
column.
编写一个解决方案,在 quantity
列中将缺失的值填充为 0
。
The result format is in the following example.
+返回结果如下示例所示。
+示例 1: +
-Example 1: -Input:+-----------------+----------+-------+ +输入: ++-----------------+----------+-------+ | name | quantity | price | +-----------------+----------+-------+ | Wristwatch | 32 | 135 | @@ -32,7 +34,7 @@ DataFrame+解释: +Toaster 和 Headphones 的数量被填充为 0。 ## 解法 diff --git a/solution/2800-2899/2888.Reshape Data Concatenate/README.md b/solution/2800-2899/2888.Reshape Data Concatenate/README.md index 55d95d79435c7..9a92f343be194 100644 --- a/solution/2800-2899/2888.Reshape Data Concatenate/README.md +++ b/solution/2800-2899/2888.Reshape Data Concatenate/README.md @@ -1,4 +1,4 @@ -# [2888. Reshape Data Concatenate](https://leetcode.cn/problems/reshape-data-concatenate) +# [2888. 重塑数据:连结](https://leetcode.cn/problems/reshape-data-concatenate) [English Version](/solution/2800-2899/2888.Reshape%20Data%20Concatenate/README_EN.md) @@ -27,15 +27,16 @@ DataFrameproducts
| GolfClubs | None | 9319 | | Printer | 849 | 3051 | +-----------------+----------+-------+ -Output: +输出: +-----------------+----------+-------+ | name | quantity | price | +-----------------+----------+-------+ @@ -41,8 +43,8 @@ DataFrameproducts
| GolfClubs | 0 | 9319 | | Printer | 849 | 3051 | +-----------------+----------+-------+ -Explanation: -The quantity for Toaster and Headphones are filled by 0.
df2
-Write a solution to concatenate these two DataFrames vertically into one DataFrame.
+编写一个解决方案,将两个 DataFrames 垂直 连接成一个 DataFrame。
-The result format is in the following example.
+结果格式如下示例所示。
-
Example 1:
+ +示例 1:
-Input: +输入: df1 +------------+---------+-----+ | student_id | name | age | @@ -52,7 +53,7 @@ df1 | 5 | Leo | 7 | | 6 | Alex | 7 | +------------+------+-----+ -Output: +输出: +------------+---------+-----+ | student_id | name | age | +------------+---------+-----+ @@ -63,8 +64,8 @@ df1 | 5 | Leo | 7 | | 6 | Alex | 7 | +------------+---------+-----+ -Explanation: -The two DataFramess are stacked vertically, and their rows are combined.+解释: +两个 DataFrame 被垂直堆叠,它们的行被合并。 ## 解法 diff --git a/solution/2800-2899/2890.Reshape Data Melt/README.md b/solution/2800-2899/2890.Reshape Data Melt/README.md index 53969a78ce91f..82ca982935c38 100644 --- a/solution/2800-2899/2890.Reshape Data Melt/README.md +++ b/solution/2800-2899/2890.Reshape Data Melt/README.md @@ -1,4 +1,4 @@ -# [2890. Reshape Data Melt](https://leetcode.cn/problems/reshape-data-melt) +# [2890. 重塑数据:融合](https://leetcode.cn/problems/reshape-data-melt) [English Version](/solution/2800-2899/2890.Reshape%20Data%20Melt/README_EN.md) @@ -19,22 +19,23 @@ DataFrame
report
+-------------+--------+
-Write a solution to reshape the data so that each row represents sales data for a product in a specific quarter.
+编写一个解决方案,将数据 重塑 成每一行表示特定季度产品销售数据的形式。
-The result format is in the following example.
+结果格式如下例所示:
-
Example 1:
+ +示例 1:
-Input:
+输入:
+-------------+-----------+-----------+-----------+-----------+
| product | quarter_1 | quarter_2 | quarter_3 | quarter_4 |
+-------------+-----------+-----------+-----------+-----------+
| Umbrella | 417 | 224 | 379 | 611 |
| SleepingBag | 800 | 936 | 93 | 875 |
+-------------+-----------+-----------+-----------+-----------+
-Output:
+输出:
+-------------+-----------+-------+
| product | quarter | sales |
+-------------+-----------+-------+
@@ -47,8 +48,8 @@ DataFrame report
| Umbrella | quarter_4 | 611 |
| SleepingBag | quarter_4 | 875 |
+-------------+-----------+-------+
-Explanation:
-The DataFrame is reshaped from wide to long format. Each row represents the sales of a product in a quarter.
+解释:
+DataFrame 已从宽格式重塑为长格式。每一行表示一个季度内产品的销售情况。
## 解法
diff --git a/solution/2800-2899/2892.Minimizing Array After Replacing Pairs With Their Product/README.md b/solution/2800-2899/2892.Minimizing Array After Replacing Pairs With Their Product/README.md
index 21fee14a7e0a9..092a89523abd8 100644
--- a/solution/2800-2899/2892.Minimizing Array After Replacing Pairs With Their Product/README.md
+++ b/solution/2800-2899/2892.Minimizing Array After Replacing Pairs With Their Product/README.md
@@ -1,4 +1,4 @@
-# [2892. Minimizing Array After Replacing Pairs With Their Product](https://leetcode.cn/problems/minimizing-array-after-replacing-pairs-with-their-product)
+# [2892. 将相邻元素相乘后得到最小化数组](https://leetcode.cn/problems/minimizing-array-after-replacing-pairs-with-their-product)
[English Version](/solution/2800-2899/2892.Minimizing%20Array%20After%20Replacing%20Pairs%20With%20Their%20Product/README_EN.md)
@@ -6,37 +6,37 @@
-Given an integer array nums
and an integer k
, you can perform the following operation on the array any number of times:
给定一个整数数组 nums
和一个整数 k
,你可以对数组执行以下操作任意次数:
x
and y
, such that x * y <= k
, and replace both of them with a single element with value x * y
(e.g. in one operation the array [1, 2, 2, 3]
with k = 5
can become [1, 4, 3]
or [2, 2, 3]
, but can't become [1, 2, 6]
).x
和 y
,使得 x * y <= k
,并用一个值为 x * y
的 单个元素 替换它们(例如,在一次操作中,数组 [1, 2, 2, 3]
,其中 k = 5
可以变为 [1, 4, 3]
或 [2, 2, 3]
,但不能变为 [1, 2, 6]
)。Return the minimum possible length of nums
after any number of operations.
返回 经过任意次数的操作后, nums
的 最小 可能长度。
-
Example 1:
+ +示例 1:
-Input: nums = [2,3,3,7,3,5], k = 20 -Output: 3 -Explanation: We perform these operations: +输入:nums = [2,3,3,7,3,5], k = 20 +输出:3 +解释:我们执行以下操作: 1. [2,3,3,7,3,5] -> [6,3,7,3,5] 2. [6,3,7,3,5] -> [18,7,3,5] 3. [18,7,3,5] -> [18,7,15] -It can be shown that 3 is the minimum length possible to achieve with the given operation. -+可以证明,在执行给定操作后,最小可能长度为3. -
Example 2:
+示例 2:
-Input: nums = [3,3,3,3], k = 6 -Output: 4 -Explanation: We can't perform any operations since the product of every two adjacent elements is greater than 6. -Hence, the answer is 4.+输入:nums = [3,3,3,3], k = 6 +输出:4 +解释:由于每两个相邻元素的乘积都大于 6,所以无法执行任何操作。因此,答案为 4。
-
Constraints:
+ +约束条件:
1 <= nums.length <= 105