Skip to content

Commit 4014d70

Browse files
authored
feat: update lc problems (doocs#3452)
1 parent f42ff99 commit 4014d70

File tree

75 files changed

+573
-13
lines changed

Some content is hidden

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

75 files changed

+573
-13
lines changed

solution/1400-1499/1409.Queries on a Permutation With Key/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,13 +35,13 @@ tags:
3535

3636
<pre>
3737
<strong>输入:</strong>queries = [3,1,2,1], m = 5
38-
<strong>输出:</strong>[2,1,2,1]
38+
<strong>输出:</strong>[2,1,2,1]
3939
<strong>解释:处理</strong> queries 的过程如下:
4040
对于 i=0: queries[i]=3, P=[1,2,3,4,5], 3 在 P 中的位置是 <strong>2</strong>,然后我们把 3 移动到 P 的开头,得到 P=[3,1,2,4,5] 。
41-
对于 i=1: queries[i]=1, P=[3,1,2,4,5], 1 在 P 中的位置是 <strong>1</strong>,然后我们把 1 移动到 P 的开头,得到 P=[1,3,2,4,5] 。
41+
对于 i=1: queries[i]=1, P=[3,1,2,4,5], 1 在 P 中的位置是 <strong>1</strong>,然后我们把 1 移动到 P 的开头,得到 P=[1,3,2,4,5] 。
4242
对于 i=2: queries[i]=2, P=[1,3,2,4,5], 2 在 P 中的位置是 <strong>2</strong>,然后我们把 2 移动到 P 的开头,得到 P=[2,1,3,4,5] 。
43-
对于 i=3: queries[i]=1, P=[2,1,3,4,5], 1 在 P 中的位置是 <strong>1</strong>,然后我们把 1 移动到 P 的开头,得到 P=[1,2,3,4,5] 。
44-
因此,包含结果的数组为 [2,1,2,1] 。
43+
对于 i=3: queries[i]=1, P=[2,1,3,4,5], 1 在 P 中的位置是 <strong>1</strong>,然后我们把 1 移动到 P 的开头,得到 P=[1,2,3,4,5] 。
44+
因此,包含结果的数组为 [2,1,2,1] 。
4545
</pre>
4646

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

solution/1400-1499/1409.Queries on a Permutation With Key/README_EN.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,13 +34,13 @@ tags:
3434

3535
<pre>
3636
<strong>Input:</strong> queries = [3,1,2,1], m = 5
37-
<strong>Output:</strong> [2,1,2,1]
38-
<strong>Explanation:</strong> The queries are processed as follow:
39-
For i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is <strong>2</strong>, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5].
40-
For i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is <strong>1</strong>, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5].
41-
For i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is <strong>2</strong>, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5].
42-
For i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is <strong>1</strong>, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5].
43-
Therefore, the array containing the result is [2,1,2,1].
37+
<strong>Output:</strong> [2,1,2,1]
38+
<strong>Explanation:</strong> The queries are processed as follow:
39+
For i=0: queries[i]=3, P=[1,2,3,4,5], position of 3 in P is <strong>2</strong>, then we move 3 to the beginning of P resulting in P=[3,1,2,4,5].
40+
For i=1: queries[i]=1, P=[3,1,2,4,5], position of 1 in P is <strong>1</strong>, then we move 1 to the beginning of P resulting in P=[1,3,2,4,5].
41+
For i=2: queries[i]=2, P=[1,3,2,4,5], position of 2 in P is <strong>2</strong>, then we move 2 to the beginning of P resulting in P=[2,1,3,4,5].
42+
For i=3: queries[i]=1, P=[2,1,3,4,5], position of 1 in P is <strong>1</strong>, then we move 1 to the beginning of P resulting in P=[1,2,3,4,5].
43+
Therefore, the array containing the result is [2,1,2,1].
4444
</pre>
4545

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

solution/3100-3199/3156.Employee Task Duration and Concurrent Tasks/README.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,13 @@ tags:
109109

110110
<!-- solution:start -->
111111

112-
### 方法一
112+
### 方法一:合并 + 连接
113+
114+
我们首先将 `employee_id``start_time``end_time` 合并到一个新的表 `T` 中,然后使用 `LEAD` 函数计算出每个员工的下一个任务的开始时间,接着我们将 `T` 表和 `Tasks` 表连接起来,计算出每个员工的并发任务数,最后按照 `employee_id` 分组,计算出每个员工的总任务时间和最大并发任务数。
115+
116+
相似题目:
117+
118+
- [3268. Find Overlapping Shifts II 🔒](https://github.com/doocs/leetcode/blob/main/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README.md)
113119

114120
<!-- tabs:start -->
115121

solution/3100-3199/3156.Employee Task Duration and Concurrent Tasks/README_EN.md

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,13 @@ Each row in this table contains the task identifier, the employee identifier, an
108108

109109
<!-- solution:start -->
110110

111-
### Solution 1
111+
### Solution 1: Merge + Join
112+
113+
First, we merge the `start_time` and `end_time` for each `employee_id` into a new table `T`. Then, using the `LEAD` function, we calculate the start time of the next task for each employee. Next, we join table `T` with the `Tasks` table to compute the concurrent task count for each employee. Finally, we group by `employee_id` to calculate the total task duration and the maximum concurrent tasks for each employee.
114+
115+
Similar Problem:
116+
117+
- [3268. Find Overlapping Shifts II 🔒](https://github.com/doocs/leetcode/blob/main/solution/3200-3299/3268.Find%20Overlapping%20Shifts%20II/README_EN.md)
112118

113119
<!-- tabs:start -->
114120

solution/3200-3299/3222.Find the Winning Player in Coin Game/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/3200-3299/3222.Find%20the%20Winning%20Player%20in%20Coin%20Game/README.md
5+
rating: 1269
6+
source: 第 135 场双周赛 Q1
57
tags:
68
- 数学
79
- 博弈

solution/3200-3299/3222.Find the Winning Player in Coin Game/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/3200-3299/3222.Find%20the%20Winning%20Player%20in%20Coin%20Game/README_EN.md
5+
rating: 1269
6+
source: Biweekly Contest 135 Q1
57
tags:
68
- Math
79
- Game Theory

solution/3200-3299/3223.Minimum Length of String After Operations/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/3200-3299/3223.Minimum%20Length%20of%20String%20After%20Operations/README.md
5+
rating: 1445
6+
source: 第 135 场双周赛 Q2
57
tags:
68
- 哈希表
79
- 字符串

solution/3200-3299/3223.Minimum Length of String After Operations/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: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3223.Minimum%20Length%20of%20String%20After%20Operations/README_EN.md
5+
rating: 1445
6+
source: Biweekly Contest 135 Q2
57
tags:
68
- Hash Table
79
- String

solution/3200-3299/3224.Minimum Array Changes to Make Differences Equal/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/3200-3299/3224.Minimum%20Array%20Changes%20to%20Make%20Differences%20Equal/README.md
5+
rating: 1996
6+
source: 第 135 场双周赛 Q3
57
tags:
68
- 数组
79
- 哈希表

solution/3200-3299/3224.Minimum Array Changes to Make Differences Equal/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: Medium
44
edit_url: https://github.com/doocs/leetcode/edit/main/solution/3200-3299/3224.Minimum%20Array%20Changes%20to%20Make%20Differences%20Equal/README_EN.md
5+
rating: 1996
6+
source: Biweekly Contest 135 Q3
57
tags:
68
- Array
79
- Hash Table

0 commit comments

Comments
 (0)