Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore: update lc problems #1766

Merged
merged 1 commit into from
Oct 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
26 changes: 26 additions & 0 deletions .github/workflows/sync.yml
Original file line number Diff line number Diff line change
@@ -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
19 changes: 10 additions & 9 deletions solution/2800-2899/2877.Create a DataFrame from List/README.md
Original file line number Diff line number Diff line change
@@ -1,30 +1,31 @@
# [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)

## 题目描述

<!-- 这里写题目描述 -->

<p>Write a solution to <strong>create</strong> a DataFrame from a 2D list called <code>student_data</code>. This 2D list contains the IDs and ages of some students.</p>
<p>编写一个解决方案,从名为 &nbsp;<code>student_data</code>&nbsp;的二维列表&nbsp;<b>创建 </b>一个 DataFrame 。这个二维列表包含一些学生的 ID 和年龄信息。</p>

<p>The DataFrame should have two columns, <code>student_id</code> and <code>age</code>, and be in the same order as the original 2D list.</p>
<p>DataFrame 应该有两列,&nbsp;<code>student_id</code>&nbsp;和&nbsp;<code>age</code>,并且与原始二维列表的顺序相同。</p>

<p>The result format is in the following example.</p>
<p>返回结果格式如下示例所示。</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<p><strong class="example">示例 1:</strong></p>

<pre>
<strong>Input:
<strong>输入:
</strong>student_data:<strong>
</strong><code>[
[1, 15],
[2, 11],
[3, 11],
[4, 20]
]</code>
<strong>Output:</strong>
<b>输出:</b>
+------------+-----+
| student_id | age |
+------------+-----+
Expand All @@ -33,8 +34,8 @@
| 3 | 11 |
| 4 | 20 |
+------------+-----+
<strong>Explanation:</strong>
A DataFrame was created on top of student_data, with two columns named <code>student_id</code> and <code>age</code>.
<b>解释:</b>
student_data 上创建了一个 DataFrame,包含 student_idage 两列。
</pre>

## 解法
Expand Down
19 changes: 10 additions & 9 deletions solution/2800-2899/2881.Create a New Column/README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -16,17 +16,18 @@ DataFrame <code>employees</code>
+-------------+--------+
</pre>

<p>A&nbsp;company plans to provide its employees with a bonus.</p>
<p>一家公司计划为员工提供奖金。</p>

<p>Write a solution to create a new column name <code>bonus</code> that contains the <strong>doubled values</strong> of the <code>salary</code> column.</p>
<p>编写一个解决方案,创建一个名为&nbsp;<code>bonus</code>&nbsp;的新列,其中包含&nbsp;<code>salary</code>&nbsp;值的&nbsp;<strong>两倍</strong>。</p>

<p>The result format is in the following example.</p>
<p>返回结果格式如下示例所示。</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<p><b>示例 1:</b></p>

<pre>
<strong>Input:</strong>
<b>输入:</b>
DataFrame employees
+---------+--------+
| name | salary |
Expand All @@ -38,7 +39,7 @@ DataFrame employees
| Finn | 74576 |
| Thomas | 24433 |
+---------+--------+
<strong>Output:</strong>
<b>输出:</b>
+---------+--------+--------+
| name | salary | bonus |
+---------+--------+--------+
Expand All @@ -49,8 +50,8 @@ DataFrame employees
| Finn | 74576 | 149152 |
| Thomas | 24433 | 48866 |
+---------+--------+--------+
<strong>Explanation:</strong>
A new column bonus is created by doubling the value in the column salary.</pre>
<b>解释:</b>
通过将salary列中的值加倍创建了一个新的bonus列。</pre>

## 解法

Expand Down
20 changes: 11 additions & 9 deletions solution/2800-2899/2882.Drop Duplicate Rows/README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -17,16 +17,18 @@ DataFrame customers
+-------------+--------+
</pre>

<p>There are some duplicate rows in the DataFrame based on the <code>email</code> column.</p>
<p>DataFrame 中基于&nbsp;<code>email</code>&nbsp;列存在一些重复行。</p>

<p>Write a solution to remove these duplicate rows and keep only the <strong>first</strong> occurrence.</p>
<p>编写一个解决方案,删除这些重复行,仅保留第一次出现的行。</p>

<p>The result format is in the following example.</p>
<p>返回结果格式如下例所示。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<pre>
<strong class="example">Example 1:</strong>
<strong>Input:</strong>
<b>输入:</b>
+-------------+---------+---------------------+
| customer_id | name | email |
+-------------+---------+---------------------+
Expand All @@ -37,7 +39,7 @@ DataFrame customers
| 5 | Finn | john@example.com |
| 6 | Violet | alice@example.com |
+-------------+---------+---------------------+
<strong>Output: </strong>
<b>输出:</b>
+-------------+---------+---------------------+
| customer_id | name | email |
+-------------+---------+---------------------+
Expand All @@ -47,8 +49,8 @@ DataFrame customers
| 4 | Alice | john@example.com |
| 6 | Violet | alice@example.com |
+-------------+---------+---------------------+
<strong>Explanation:</strong>
Alic (customer_id = 4) and Finn (customer_id = 5) both use john@example.com, so only the first occurrence of this email is retained.
<b>解释:</b>
Alice (customer_id = 4) Finn (customer_id = 5) 都使用 john@example.com,因此只保留该邮箱地址的第一次出现。
</pre>

## 解法
Expand Down
19 changes: 10 additions & 9 deletions solution/2800-2899/2883.Drop Missing Data/README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -17,17 +17,18 @@ DataFrame students
+-------------+--------+
</pre>

<p>There are some rows having missing values in the <code>name</code> column.</p>
<p><code>name</code> 列里有一些具有缺失值的行。</p>

<p>Write a solution to remove the rows with missing values.</p>
<p>编写一个解决方案,删除具有缺失值的行。</p>

<p>The result format is in the following example.</p>
<p>返回结果格式如下示例所示。</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<p><b>示例 1:</b></p>

<pre>
<strong>Input:
<strong>输入:
</strong>+------------+-------+-----+
| student_id | name | age |
+------------+-------+-----+
Expand All @@ -36,15 +37,15 @@ DataFrame students
| 779 | None | 20 |
| 849 | None | 14 |
+------------+-------+-----+
<strong>Output:
<strong>输出:
</strong>+------------+-------+-----+
| student_id | name | age |
+------------+-------+-----+
| 32 | Piper | 5 |
| 217 | Grace | 19 |
+------------+-------+-----+
<strong>Explanation:</strong>
Students with ids 779 and 849 have empty values in the name column, so they will be removed.</pre>
<b>解释:
</b>学号为 779 849 的学生所在行在 name 列中有空值,因此它们将被删除。</pre>

## 解法

Expand Down
19 changes: 10 additions & 9 deletions solution/2800-2899/2884.Modify Columns/README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -16,17 +16,18 @@ DataFrame <code>employees</code>
+-------------+--------+
</pre>

<p>A company intends to give its employees a pay rise.</p>
<p>一家公司决定增加员工的薪水。</p>

<p>Write a solution to <strong>modify</strong> the <code>salary</code> column by multiplying each salary by 2.</p>
<p>编写一个解决方案,将每个员工的薪水乘以2来 <strong>修改</strong>&nbsp;<code>salary</code>&nbsp;列。</p>

<p>The result format is in the following example.</p>
<p>返回结果格式如下示例所示。</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<p><b>示例 1:</b></p>

<pre>
<strong>Input:
<strong>输入:
</strong>DataFrame employees
+---------+--------+
| name | salary |
Expand All @@ -36,7 +37,7 @@ DataFrame <code>employees</code>
| Mia | 62509 |
| Ulysses | 54866 |
+---------+--------+
<strong>Output:
<strong>输出:
</strong>+---------+--------+
| name | salary |
+---------+--------+
Expand All @@ -45,8 +46,8 @@ DataFrame <code>employees</code>
| Mia | 125018 |
| Ulysses | 109732 |
+---------+--------+
<strong>Explanation:
</strong>Every salary has been doubled.</pre>
<strong>解释:
</strong>每个人的薪水都被加倍。</pre>

## 解法

Expand Down
26 changes: 14 additions & 12 deletions solution/2800-2899/2885.Rename Columns/README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -18,21 +18,23 @@ DataFrame <code>students</code>
+-------------+--------+
</pre>

<p>Write a solution to rename the columns as follows:</p>
<p>编写一个解决方案,按以下方式重命名列:</p>

<ul>
<li><code>id</code> to <code>student_id</code></li>
<li><code>first</code> to <code>first_name</code></li>
<li><code>last</code> to <code>last_name</code></li>
<li><code>age</code> to <code>age_in_years</code></li>
<li><code>id</code>&nbsp;重命名为&nbsp;<code>student_id</code></li>
<li><code>first</code>&nbsp;重命名为&nbsp;<code>first_name</code></li>
<li><code>last</code>&nbsp;重命名为&nbsp;<code>last_name</code></li>
<li><code>age</code>&nbsp;重命名为&nbsp;<code>age_in_years</code></li>
</ul>

<p>The result format is in the following example.</p>
<p>返回结果格式如下示例所示。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<pre>
<strong class="example">Example 1:</strong>
<strong>Input:
<strong>输入:
</strong>+----+---------+----------+-----+
| id | first | last | age |
+----+---------+----------+-----+
Expand All @@ -42,7 +44,7 @@ DataFrame <code>students</code>
| 4 | Georgia | Thompson | 18 |
| 5 | Thomas | Moore | 10 |
+----+---------+----------+-----+
<strong>Output:</strong>
<b>输出:</b>
+------------+------------+-----------+--------------+
| student_id | first_name | last_name | age_in_years |
+------------+------------+-----------+--------------+
Expand All @@ -52,8 +54,8 @@ DataFrame <code>students</code>
| 4 | Georgia | Thompson | 18 |
| 5 | Thomas | Moore | 10 |
+------------+------------+-----------+--------------+
<strong>Explanation:</strong>
The column names are changed accordingly.</pre>
<b>解释:</b>
列名已相应更换。</pre>

## 解法

Expand Down
20 changes: 11 additions & 9 deletions solution/2800-2899/2886.Change Data Type/README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand All @@ -18,32 +18,34 @@ DataFrame <code>students</code>
+-------------+--------+
</pre>

<p>Write a solution to correct the errors:</p>
<p>编写一个解决方案来纠正以下错误:</p>

<p>The <code>grade</code> column is stored as floats,&nbsp;convert it to integers.</p>
<p>&nbsp;<code>grade</code>&nbsp;列被存储为浮点数,将它转换为整数。</p>

<p>The result format is in the following example.</p>
<p>返回结果格式如下示例所示。</p>

<p>&nbsp;</p>

<p><strong>示例 1:</strong></p>

<pre>
<strong class="example">Example 1:</strong>
<strong>Input:
<strong>输入:
</strong>DataFrame students:
+------------+------+-----+-------+
| student_id | name | age | grade |
+------------+------+-----+-------+
| 1 | Ava | 6 | 73.0 |
| 2 | Kate | 15 | 87.0 |
+------------+------+-----+-------+
<strong>Output:
<strong>输出:
</strong>+------------+------+-----+-------+
| student_id | name | age | grade |
+------------+------+-----+-------+
| 1 | Ava | 6 | 73 |
| 2 | Kate | 15 | 87 |
+------------+------+-----+-------+
<strong>Explanation:</strong>
The data types of the column grade is converted to int.</pre>
<b>解释:</b>
grade 列的数据类型已转换为整数。</pre>

## 解法

Expand Down
Loading