Skip to content

Commit 40e10d2

Browse files
committed
feat: add weekly contest 476
1 parent 126c576 commit 40e10d2

File tree

44 files changed

+1220
-66
lines changed

Some content is hidden

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

44 files changed

+1220
-66
lines changed

solution/0600-0699/0627.Swap Salary/Solution.sql

Lines changed: 0 additions & 5 deletions
This file was deleted.

solution/0600-0699/0627.Swap Salary/README.md renamed to solution/0600-0699/0627.Swap Sex of Employees/README.md

Lines changed: 5 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
comments: true
33
difficulty: 简单
4-
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Salary/README.md
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Sex%20of%20Employees/README.md
55
tags:
66
- 数据库
77
---
88

99
<!-- problem:start -->
1010

11-
# [627. 变更性别](https://leetcode.cn/problems/swap-salary)
11+
# [627. 变更性别](https://leetcode.cn/problems/swap-sex-of-employees)
1212

13-
[English Version](/solution/0600-0699/0627.Swap%20Salary/README_EN.md)
13+
[English Version](/solution/0600-0699/0627.Swap%20Sex%20of%20Employees/README_EN.md)
1414

1515
## 题目描述
1616

@@ -78,27 +78,9 @@ Salary 表:
7878

7979
<!-- solution:start -->
8080

81-
### 方法一
81+
### 方法一:使用单个 update 语句交换性别
8282

83-
<!-- tabs:start -->
84-
85-
#### MySQL
86-
87-
```sql
88-
UPDATE salary
89-
SET sex = CASE sex
90-
WHEN 'm' THEN 'f'
91-
ELSE 'm'
92-
END;
93-
```
94-
95-
<!-- tabs:end -->
96-
97-
<!-- solution:end -->
98-
99-
<!-- solution:start -->
100-
101-
### 方法二
83+
根据题目要求,我们只需要使用一条 update 语句来交换所有员工的性别。我们可以使用 SQL 中的条件表达式来实现这一点。
10284

10385
<!-- tabs:start -->
10486

solution/0600-0699/0627.Swap Salary/README_EN.md renamed to solution/0600-0699/0627.Swap Sex of Employees/README_EN.md

Lines changed: 8 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
---
22
comments: true
33
difficulty: Easy
4-
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Salary/README_EN.md
4+
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Sex%20of%20Employees/README_EN.md
55
tags:
66
- Database
77
---
88

99
<!-- problem:start -->
1010

11-
# [627. Swap Salary](https://leetcode.com/problems/swap-salary)
11+
# [627. Swap Sex of Employees](https://leetcode.com/problems/swap-sex-of-employees)
1212

13-
[中文文档](/solution/0600-0699/0627.Swap%20Salary/README.md)
13+
[中文文档](/solution/0600-0699/0627.Swap%20Sex%20of%20Employees/README.md)
1414

1515
## Description
1616

@@ -44,7 +44,7 @@ The table contains information about an employee.
4444
<p><strong class="example">Example 1:</strong></p>
4545

4646
<pre>
47-
<strong>Input:</strong>
47+
<strong>Input:</strong>
4848
Salary table:
4949
+----+------+-----+--------+
5050
| id | name | sex | salary |
@@ -54,7 +54,7 @@ Salary table:
5454
| 3 | C | m | 5500 |
5555
| 4 | D | f | 500 |
5656
+----+------+-----+--------+
57-
<strong>Output:</strong>
57+
<strong>Output:</strong>
5858
+----+------+-----+--------+
5959
| id | name | sex | salary |
6060
+----+------+-----+--------+
@@ -63,7 +63,7 @@ Salary table:
6363
| 3 | C | f | 5500 |
6464
| 4 | D | m | 500 |
6565
+----+------+-----+--------+
66-
<strong>Explanation:</strong>
66+
<strong>Explanation:</strong>
6767
(1, A) and (3, C) were changed from &#39;m&#39; to &#39;f&#39;.
6868
(2, B) and (4, D) were changed from &#39;f&#39; to &#39;m&#39;.
6969
</pre>
@@ -74,27 +74,9 @@ Salary table:
7474

7575
<!-- solution:start -->
7676

77-
### Solution 1
77+
### Solution 1: Swap Sex Using a Single UPDATE Statement
7878

79-
<!-- tabs:start -->
80-
81-
#### MySQL
82-
83-
```sql
84-
UPDATE salary
85-
SET sex = CASE sex
86-
WHEN 'm' THEN 'f'
87-
ELSE 'm'
88-
END;
89-
```
90-
91-
<!-- tabs:end -->
92-
93-
<!-- solution:end -->
94-
95-
<!-- solution:start -->
96-
97-
### Solution 2
79+
According to the problem requirements, we only need to use a single UPDATE statement to swap the sex of all employees. We can achieve this using conditional expressions in SQL.
9880

9981
<!-- tabs:start -->
10082

solution/2500-2599/2527.Find Xor-Beauty of Array/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ tags:
5151
- (1,0,0) 有效值为 ((4 | 1) &amp; 1) = 1
5252
- (1,0,1) 有效值为 ((4 | 1) &amp; 4) = 4
5353
- (1,1,0) 有效值为 ((4 | 4) &amp; 1) = 0
54-
- (1,1,1) 有效值为 ((4 | 4) &amp; 4) = 4
54+
- (1,1,1) 有效值为 ((4 | 4) &amp; 4) = 4
5555
数组的异或美丽值为所有有效值的按位异或 1 ^ 0 ^ 1 ^ 4 ^ 1 ^ 4 ^ 0 ^ 4 = 5 。</pre>
5656

5757
<p><strong>示例 2:</strong></p>

solution/2500-2599/2527.Find Xor-Beauty of Array/README_EN.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ tags:
4141
<pre>
4242
<strong>Input:</strong> nums = [1,4]
4343
<strong>Output:</strong> 5
44-
<strong>Explanation:</strong>
44+
<strong>Explanation:</strong>
4545
The triplets and their corresponding effective values are listed below:
4646
- (0,0,0) with effective value ((1 | 1) &amp; 1) = 1
4747
- (0,0,1) with effective value ((1 | 1) &amp; 4) = 0
@@ -50,7 +50,7 @@ The triplets and their corresponding effective values are listed below:
5050
- (1,0,0) with effective value ((4 | 1) &amp; 1) = 1
5151
- (1,0,1) with effective value ((4 | 1) &amp; 4) = 4
5252
- (1,1,0) with effective value ((4 | 4) &amp; 1) = 0
53-
- (1,1,1) with effective value ((4 | 4) &amp; 4) = 4
53+
- (1,1,1) with effective value ((4 | 4) &amp; 4) = 4
5454
Xor-beauty of array will be bitwise XOR of all beauties = 1 ^ 0 ^ 1 ^ 4 ^ 1 ^ 4 ^ 0 ^ 4 = 5.</pre>
5555

5656
<p><strong class="example">Example 2:</strong></p>

solution/2500-2599/2536.Increment Submatrices by One/README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ tags:
4040
<strong>输入:</strong>n = 3, queries = [[1,1,2,2],[0,0,1,1]]
4141
<strong>输出:</strong>[[1,1,0],[1,2,1],[0,1,1]]
4242
<strong>解释:</strong>上图所展示的分别是:初始矩阵、执行完第一个操作后的矩阵、执行完第二个操作后的矩阵。
43-
- 第一个操作:将左上角为 (1, 1) 且右下角为 (2, 2) 的子矩阵中的每个元素加 1 。
44-
- 第二个操作:将左上角为 (0, 0) 且右下角为 (1, 1) 的子矩阵中的每个元素加 1 。
43+
- 第一个操作:将左上角为 (1, 1) 且右下角为 (2, 2) 的子矩阵中的每个元素加 1 。
44+
- 第二个操作:将左上角为 (0, 0) 且右下角为 (1, 1) 的子矩阵中的每个元素加 1 。
4545
</pre>
4646

4747
<p><strong>示例 2:</strong></p>
@@ -51,7 +51,7 @@ tags:
5151
<pre>
5252
<strong>输入:</strong>n = 2, queries = [[0,0,1,1]]
5353
<strong>输出:</strong>[[1,1],[1,1]]
54-
<strong>解释:</strong>上图所展示的分别是:初始矩阵、执行完第一个操作后的矩阵。
54+
<strong>解释:</strong>上图所展示的分别是:初始矩阵、执行完第一个操作后的矩阵。
5555
- 第一个操作:将矩阵中的每个元素加 1 。</pre>
5656

5757
<p>&nbsp;</p>

solution/3700-3799/3736.Minimum Moves to Equal Array Elements III/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 简单
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3736.Minimum%20Moves%20to%20Equal%20Array%20Elements%20III/README.md
5+
rating: 1251
6+
source: 第 169 场双周赛 Q1
57
---
68

79
<!-- problem:start -->

solution/3700-3799/3736.Minimum Moves to Equal Array Elements III/README_EN.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: Easy
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3736.Minimum%20Moves%20to%20Equal%20Array%20Elements%20III/README_EN.md
5+
rating: 1251
6+
source: Biweekly Contest 169 Q1
57
---
68

79
<!-- problem:start -->

solution/3700-3799/3737.Count Subarrays With Majority Element I/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,8 @@
22
comments: true
33
difficulty: 中等
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3737.Count%20Subarrays%20With%20Majority%20Element%20I/README.md
5+
rating: 1422
6+
source: 第 169 场双周赛 Q2
57
---
68

79
<!-- problem:start -->

0 commit comments

Comments
 (0)