Skip to content
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
5 changes: 0 additions & 5 deletions solution/0600-0699/0627.Swap Salary/Solution.sql

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Salary/README.md
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Sex%20of%20Employees/README.md
tags:
- 数据库
---

<!-- problem:start -->

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

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

## 题目描述

Expand Down Expand Up @@ -78,27 +78,9 @@ Salary 表:

<!-- solution:start -->

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

<!-- tabs:start -->

#### MySQL

```sql
UPDATE salary
SET sex = CASE sex
WHEN 'm' THEN 'f'
ELSE 'm'
END;
```

<!-- tabs:end -->

<!-- solution:end -->

<!-- solution:start -->

### 方法二
根据题目要求,我们只需要使用一条 update 语句来交换所有员工的性别。我们可以使用 SQL 中的条件表达式来实现这一点。

<!-- tabs:start -->

Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,16 @@
---
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Salary/README_EN.md
edit_url: https://github.com/doocs/leetcode/edit/main/solution/0600-0699/0627.Swap%20Sex%20of%20Employees/README_EN.md
tags:
- Database
---

<!-- problem:start -->

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

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

## Description

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

<pre>
<strong>Input:</strong>
<strong>Input:</strong>
Salary table:
+----+------+-----+--------+
| id | name | sex | salary |
Expand All @@ -54,7 +54,7 @@ Salary table:
| 3 | C | m | 5500 |
| 4 | D | f | 500 |
+----+------+-----+--------+
<strong>Output:</strong>
<strong>Output:</strong>
+----+------+-----+--------+
| id | name | sex | salary |
+----+------+-----+--------+
Expand All @@ -63,7 +63,7 @@ Salary table:
| 3 | C | f | 5500 |
| 4 | D | m | 500 |
+----+------+-----+--------+
<strong>Explanation:</strong>
<strong>Explanation:</strong>
(1, A) and (3, C) were changed from &#39;m&#39; to &#39;f&#39;.
(2, B) and (4, D) were changed from &#39;f&#39; to &#39;m&#39;.
</pre>
Expand All @@ -74,27 +74,9 @@ Salary table:

<!-- solution:start -->

### Solution 1
### Solution 1: Swap Sex Using a Single UPDATE Statement

<!-- tabs:start -->

#### MySQL

```sql
UPDATE salary
SET sex = CASE sex
WHEN 'm' THEN 'f'
ELSE 'm'
END;
```

<!-- tabs:end -->

<!-- solution:end -->

<!-- solution:start -->

### Solution 2
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.

<!-- tabs:start -->

Expand Down
2 changes: 1 addition & 1 deletion solution/2500-2599/2527.Find Xor-Beauty of Array/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ tags:
- (1,0,0) 有效值为 ((4 | 1) &amp; 1) = 1
- (1,0,1) 有效值为 ((4 | 1) &amp; 4) = 4
- (1,1,0) 有效值为 ((4 | 4) &amp; 1) = 0
- (1,1,1) 有效值为 ((4 | 4) &amp; 4) = 4
- (1,1,1) 有效值为 ((4 | 4) &amp; 4) = 4
数组的异或美丽值为所有有效值的按位异或 1 ^ 0 ^ 1 ^ 4 ^ 1 ^ 4 ^ 0 ^ 4 = 5 。</pre>

<p><strong>示例 2:</strong></p>
Expand Down
4 changes: 2 additions & 2 deletions solution/2500-2599/2527.Find Xor-Beauty of Array/README_EN.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ tags:
<pre>
<strong>Input:</strong> nums = [1,4]
<strong>Output:</strong> 5
<strong>Explanation:</strong>
<strong>Explanation:</strong>
The triplets and their corresponding effective values are listed below:
- (0,0,0) with effective value ((1 | 1) &amp; 1) = 1
- (0,0,1) with effective value ((1 | 1) &amp; 4) = 0
Expand All @@ -50,7 +50,7 @@ The triplets and their corresponding effective values are listed below:
- (1,0,0) with effective value ((4 | 1) &amp; 1) = 1
- (1,0,1) with effective value ((4 | 1) &amp; 4) = 4
- (1,1,0) with effective value ((4 | 4) &amp; 1) = 0
- (1,1,1) with effective value ((4 | 4) &amp; 4) = 4
- (1,1,1) with effective value ((4 | 4) &amp; 4) = 4
Xor-beauty of array will be bitwise XOR of all beauties = 1 ^ 0 ^ 1 ^ 4 ^ 1 ^ 4 ^ 0 ^ 4 = 5.</pre>

<p><strong class="example">Example 2:</strong></p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ tags:
<strong>输入:</strong>n = 3, queries = [[1,1,2,2],[0,0,1,1]]
<strong>输出:</strong>[[1,1,0],[1,2,1],[0,1,1]]
<strong>解释:</strong>上图所展示的分别是:初始矩阵、执行完第一个操作后的矩阵、执行完第二个操作后的矩阵。
- 第一个操作:将左上角为 (1, 1) 且右下角为 (2, 2) 的子矩阵中的每个元素加 1 。
- 第二个操作:将左上角为 (0, 0) 且右下角为 (1, 1) 的子矩阵中的每个元素加 1 。
- 第一个操作:将左上角为 (1, 1) 且右下角为 (2, 2) 的子矩阵中的每个元素加 1 。
- 第二个操作:将左上角为 (0, 0) 且右下角为 (1, 1) 的子矩阵中的每个元素加 1 。
</pre>

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

<p>&nbsp;</p>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3736.Minimum%20Moves%20to%20Equal%20Array%20Elements%20III/README.md
rating: 1251
source: 第 169 场双周赛 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3736.Minimum%20Moves%20to%20Equal%20Array%20Elements%20III/README_EN.md
rating: 1251
source: Biweekly Contest 169 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3737.Count%20Subarrays%20With%20Majority%20Element%20I/README.md
rating: 1422
source: 第 169 场双周赛 Q2
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3737.Count%20Subarrays%20With%20Majority%20Element%20I/README_EN.md
rating: 1422
source: Biweekly Contest 169 Q2
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3738.Longest%20Non-Decreasing%20Subarray%20After%20Replacing%20at%20Most%20One%20Element/README.md
rating: 1811
source: 第 169 场双周赛 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3738.Longest%20Non-Decreasing%20Subarray%20After%20Replacing%20at%20Most%20One%20Element/README_EN.md
rating: 1811
source: Biweekly Contest 169 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3739.Count%20Subarrays%20With%20Majority%20Element%20II/README.md
rating: 2089
source: 第 169 场双周赛 Q4
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3739.Count%20Subarrays%20With%20Majority%20Element%20II/README_EN.md
rating: 2089
source: Biweekly Contest 169 Q4
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 简单
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3740.Minimum%20Distance%20Between%20Three%20Equal%20Elements%20I/README.md
rating: 1287
source: 第 475 场周赛 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Easy
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3740.Minimum%20Distance%20Between%20Three%20Equal%20Elements%20I/README_EN.md
rating: 1287
source: Weekly Contest 475 Q1
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3741.Minimum%20Distance%20Between%20Three%20Equal%20Elements%20II/README.md
rating: 1449
source: 第 475 场周赛 Q2
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3741.Minimum%20Distance%20Between%20Three%20Equal%20Elements%20II/README_EN.md
rating: 1449
source: Weekly Contest 475 Q2
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 中等
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3742.Maximum%20Path%20Score%20in%20a%20Grid/README.md
rating: 1804
source: 第 475 场周赛 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Medium
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3742.Maximum%20Path%20Score%20in%20a%20Grid/README_EN.md
rating: 1804
source: Weekly Contest 475 Q3
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: 困难
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3743.Maximize%20Cyclic%20Partition%20Score/README.md
rating: 3124
source: 第 475 场周赛 Q4
---

<!-- problem:start -->
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
comments: true
difficulty: Hard
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3700-3799/3743.Maximize%20Cyclic%20Partition%20Score/README_EN.md
rating: 3124
source: Weekly Contest 475 Q4
---

<!-- problem:start -->
Expand Down
Loading
Loading