= S
+ .chars()
+ .map(|c| c.to_digit(10).unwrap() as usize)
+ .collect();
+ let k = k as usize;
+ let mut ans = MIN;
+
+ for a in 0..5 {
+ for b in 0..5 {
+ if a == b {
+ continue;
+ }
+
+ let mut curA = 0;
+ let mut curB = 0;
+ let mut preA = 0;
+ let mut preB = 0;
+ let mut t = [[MAX; 2]; 2];
+ let mut l: isize = -1;
+
+ for (r, &x) in s.iter().enumerate() {
+ curA += (x == a) as i32;
+ curB += (x == b) as i32;
+
+ while (r as isize - l) as usize >= k && curB - preB >= 2 {
+ let i = (preA & 1) as usize;
+ let j = (preB & 1) as usize;
+ t[i][j] = min(t[i][j], preA - preB);
+ l += 1;
+ if l >= 0 {
+ preA += (s[l as usize] == a) as i32;
+ preB += (s[l as usize] == b) as i32;
+ }
+ }
+
+ let i = (curA & 1 ^ 1) as usize;
+ let j = (curB & 1) as usize;
+ if t[i][j] != MAX {
+ ans = max(ans, curA - curB - t[i][j]);
+ }
+ }
+ }
+ }
+
+ ans
+ }
+}
diff --git a/solution/3500-3599/3565.Sequential Grid Path Cover/README.md b/solution/3500-3599/3565.Sequential Grid Path Cover/README.md
index b222082e1362d..00e1d79864415 100644
--- a/solution/3500-3599/3565.Sequential Grid Path Cover/README.md
+++ b/solution/3500-3599/3565.Sequential Grid Path Cover/README.md
@@ -62,8 +62,8 @@ tags:
提示:
+-------------+---------+
@@ -25,11 +25,11 @@ tags:
| employee_id | int |
| name | varchar |
+-------------+---------+
-employee_id is the unique identifier for this table.
-Each row contains information about an employee.
+employee_id 是这张表的唯一主键。
+每一行包含一名员工的信息。
-Table: performance_reviews
+表:performance_reviews
+-------------+------+
@@ -40,30 +40,31 @@ Each row contains information about an employee.
| review_date | date |
| rating | int |
+-------------+------+
-review_id is the unique identifier for this table.
-Each row represents a performance review for an employee. The rating is on a scale of 1-5 where 5 is excellent and 1 is poor.
+review_id 是这张表的唯一主键。
+每一行表示一名员工的绩效评估。评分在 1-5 的范围内,5分代表优秀,1分代表较差。
-Write a solution to find employees who have consistently improved their performance over their last three reviews.
+编写一个解决方案,以找到在过去三次评估中持续提高绩效的员工。
- - An employee must have at least
3
review to be considered
- - The employee's last
3
reviews must show strictly increasing ratings (each review better than the previous)
- - Use the most recent
3
reviews based on review_date
for each employee
- - Calculate the improvement score as the difference between the latest rating and the earliest rating among the last
3
reviews
+ - 员工 至少需要
3
次评估 才能被考虑
+ - 员工过去的
3
次评估,评分必须 严格递增(每次评价都比上一次好)
+ - 根据
review_date
为每位员工分析最近的 3
次评估
+ - 进步分数 为最后
3
次评估中最后一次评分与最早一次评分之间的差值
-Return the result table ordered by improvement score in descending order, then by name in ascending order.
+返回结果表以 进步分数 降序 排序,然后以 名字 升序 排序。
-The result format is in the following example.
+结果格式如下所示。
-Example:
+
+示例:
-
Input:
+
输入:
-
employees table:
+
employees 表:
+-------------+----------------+
@@ -77,7 +78,7 @@ Each row represents a performance review for an employee. The rating is on a sca
+-------------+----------------+
-
performance_reviews table:
+
performance_reviews 表:
+-----------+-------------+-------------+--------+
@@ -103,7 +104,7 @@ Each row represents a performance review for an employee. The rating is on a sca
+-----------+-------------+-------------+--------+
-
Output:
+
输出:
+-------------+----------------+-------------------+
@@ -115,44 +116,44 @@ Each row represents a performance review for an employee. The rating is on a sca
+-------------+----------------+-------------------+
-
Explanation:
+
解释:
- - Alice Johnson (employee_id = 1):
+
- Alice Johnson (employee_id = 1):
- - Has 4 reviews with ratings: 2, 3, 4, 5
- - Last 3 reviews (by date): 2023-04-15 (3), 2023-07-15 (4), 2023-10-15 (5)
- - Ratings are strictly increasing: 3 → 4 → 5
- - Improvement score: 5 - 3 = 2
+ - 有 4 次评估,分数:2, 3, 4, 5
+ - 最后 3 次评估(按日期):2023-04-15 (3), 2023-07-15 (4), 2023-10-15 (5)
+ - 评分严格递增:3 → 4 → 5
+ - 进步分数:5 - 3 = 2
- - Carol Davis (employee_id = 3):
+
- Carol Davis (employee_id = 3):
- - Has 4 reviews with ratings: 1, 2, 3, 4
- - Last 3 reviews (by date): 2023-06-10 (2), 2023-09-10 (3), 2023-12-10 (4)
- - Ratings are strictly increasing: 2 → 3 → 4
- - Improvement score: 4 - 2 = 2
+ - 有 4 次评估,分数:1, 2, 3, 4
+ - 最后 3 次评估(按日期):2023-06-10 (2),2023-09-10 (3),2023-12-10 (4)
+ - 评分严格递增:2 → 3 → 4
+ - 进步分数:4 - 2 = 2
- - Bob Smith (employee_id = 2):
+
- Bob Smith (employee_id = 2):
- - Has 4 reviews with ratings: 3, 2, 4, 5
- - Last 3 reviews (by date): 2023-05-01 (2), 2023-08-01 (4), 2023-11-01 (5)
- - Ratings are strictly increasing: 2 → 4 → 5
- - Improvement score: 5 - 2 = 3
+ - 有 4 次评估,分数:3,2,4,5
+ - 最后 3 次评估(按日期):2023-05-01 (2),2023-08-01 (4),2023-11-01 (5)
+ - 评分严格递增:2 → 4 → 5
+ - 进步分数:5 - 2 = 3
- - Employees not included:
+
- 未包含的员工:
- - David Wilson (employee_id = 4): Last 3 reviews are all 4 (no improvement)
- - Emma Brown (employee_id = 5): Only has 2 reviews (needs at least 3)
+ - David Wilson (employee_id = 4):之前 3 次评估都是 4 分(没有进步)
+ - Emma Brown (employee_id = 5):只有 2 次评估(需要至少 3 次)
-
The output table is ordered by improvement_score in descending order, then by name in ascending order.
+
输出表以 improvement_score 降序排序,然后以 name 升序排序。
diff --git a/solution/DATABASE_README.md b/solution/DATABASE_README.md
index e9894b6773bc4..52f5095c35876 100644
--- a/solution/DATABASE_README.md
+++ b/solution/DATABASE_README.md
@@ -318,7 +318,7 @@
| 3554 | [查找类别推荐对](/solution/3500-3599/3554.Find%20Category%20Recommendation%20Pairs/README.md) | `数据库` | 困难 | |
| 3564 | [季节性销售分析](/solution/3500-3599/3564.Seasonal%20Sales%20Analysis/README.md) | `数据库` | 中等 | |
| 3570 | [查找无可用副本的书籍](/solution/3500-3599/3570.Find%20Books%20with%20No%20Available%20Copies/README.md) | `数据库` | 简单 | |
-| 3580 | [Find Consistently Improving Employees](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README.md) | | 中等 | |
+| 3580 | [寻找持续进步的员工](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README.md) | `数据库` | 中等 | |
## 版权
diff --git a/solution/DATABASE_README_EN.md b/solution/DATABASE_README_EN.md
index 4cbbd4ee46c86..ec91b94dff34f 100644
--- a/solution/DATABASE_README_EN.md
+++ b/solution/DATABASE_README_EN.md
@@ -316,7 +316,7 @@ Press Control + F(or Command + F on
| 3554 | [Find Category Recommendation Pairs](/solution/3500-3599/3554.Find%20Category%20Recommendation%20Pairs/README_EN.md) | `Database` | Hard | |
| 3564 | [Seasonal Sales Analysis](/solution/3500-3599/3564.Seasonal%20Sales%20Analysis/README_EN.md) | `Database` | Medium | |
| 3570 | [Find Books with No Available Copies](/solution/3500-3599/3570.Find%20Books%20with%20No%20Available%20Copies/README_EN.md) | `Database` | Easy | |
-| 3580 | [Find Consistently Improving Employees](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README_EN.md) | | Medium | |
+| 3580 | [Find Consistently Improving Employees](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README_EN.md) | `Database` | Medium | |
## Copyright
diff --git a/solution/README.md b/solution/README.md
index 81f5503777c52..2b6339782fa66 100644
--- a/solution/README.md
+++ b/solution/README.md
@@ -3581,16 +3581,16 @@
| 3568 | [清理教室的最少移动](/solution/3500-3599/3568.Minimum%20Moves%20to%20Clean%20the%20Classroom/README.md) | `位运算`,`广度优先搜索`,`数组`,`哈希表`,`矩阵` | 中等 | 第 452 场周赛 |
| 3569 | [分割数组后不同质数的最大数目](/solution/3500-3599/3569.Maximize%20Count%20of%20Distinct%20Primes%20After%20Split/README.md) | `线段树`,`数组`,`数学`,`数论` | 困难 | 第 452 场周赛 |
| 3570 | [查找无可用副本的书籍](/solution/3500-3599/3570.Find%20Books%20with%20No%20Available%20Copies/README.md) | `数据库` | 简单 | |
-| 3571 | [最短超级串 II](/solution/3500-3599/3571.Find%20the%20Shortest%20Superstring%20II/README.md) | | 简单 | 🔒 |
-| 3572 | [选择不同 X 值三元组使 Y 值之和最大](/solution/3500-3599/3572.Maximize%20Y%E2%80%91Sum%20by%20Picking%20a%20Triplet%20of%20Distinct%20X%E2%80%91Values/README.md) | | 中等 | 第 158 场双周赛 |
-| 3573 | [买卖股票的最佳时机 V](/solution/3500-3599/3573.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20V/README.md) | | 中等 | 第 158 场双周赛 |
-| 3574 | [最大子数组 GCD 分数](/solution/3500-3599/3574.Maximize%20Subarray%20GCD%20Score/README.md) | | 困难 | 第 158 场双周赛 |
-| 3575 | [最大好子树分数](/solution/3500-3599/3575.Maximum%20Good%20Subtree%20Score/README.md) | | 困难 | 第 158 场双周赛 |
-| 3576 | [数组元素相等转换](/solution/3500-3599/3576.Transform%20Array%20to%20All%20Equal%20Elements/README.md) | | 中等 | 第 453 场周赛 |
-| 3577 | [统计计算机解锁顺序排列数](/solution/3500-3599/3577.Count%20the%20Number%20of%20Computer%20Unlocking%20Permutations/README.md) | | 中等 | 第 453 场周赛 |
-| 3578 | [统计极差最大为 K 的分割方式数](/solution/3500-3599/3578.Count%20Partitions%20With%20Max-Min%20Difference%20at%20Most%20K/README.md) | | 中等 | 第 453 场周赛 |
-| 3579 | [字符串转换需要的最小操作数](/solution/3500-3599/3579.Minimum%20Steps%20to%20Convert%20String%20with%20Operations/README.md) | | 困难 | 第 453 场周赛 |
-| 3580 | [Find Consistently Improving Employees](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README.md) | | 中等 | |
+| 3571 | [最短超级串 II](/solution/3500-3599/3571.Find%20the%20Shortest%20Superstring%20II/README.md) | `字符串` | 简单 | 🔒 |
+| 3572 | [选择不同 X 值三元组使 Y 值之和最大](/solution/3500-3599/3572.Maximize%20Y%E2%80%91Sum%20by%20Picking%20a%20Triplet%20of%20Distinct%20X%E2%80%91Values/README.md) | `贪心`,`数组`,`哈希表`,`排序`,`堆(优先队列)` | 中等 | 第 158 场双周赛 |
+| 3573 | [买卖股票的最佳时机 V](/solution/3500-3599/3573.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20V/README.md) | `数组`,`动态规划` | 中等 | 第 158 场双周赛 |
+| 3574 | [最大子数组 GCD 分数](/solution/3500-3599/3574.Maximize%20Subarray%20GCD%20Score/README.md) | `数组`,`数学`,`枚举`,`数论` | 困难 | 第 158 场双周赛 |
+| 3575 | [最大好子树分数](/solution/3500-3599/3575.Maximum%20Good%20Subtree%20Score/README.md) | `位运算`,`树`,`深度优先搜索`,`数组`,`动态规划`,`状态压缩` | 困难 | 第 158 场双周赛 |
+| 3576 | [数组元素相等转换](/solution/3500-3599/3576.Transform%20Array%20to%20All%20Equal%20Elements/README.md) | `贪心`,`数组` | 中等 | 第 453 场周赛 |
+| 3577 | [统计计算机解锁顺序排列数](/solution/3500-3599/3577.Count%20the%20Number%20of%20Computer%20Unlocking%20Permutations/README.md) | `脑筋急转弯`,`数组`,`数学`,`组合数学` | 中等 | 第 453 场周赛 |
+| 3578 | [统计极差最大为 K 的分割方式数](/solution/3500-3599/3578.Count%20Partitions%20With%20Max-Min%20Difference%20at%20Most%20K/README.md) | `队列`,`数组`,`动态规划`,`前缀和`,`滑动窗口`,`单调队列` | 中等 | 第 453 场周赛 |
+| 3579 | [字符串转换需要的最小操作数](/solution/3500-3599/3579.Minimum%20Steps%20to%20Convert%20String%20with%20Operations/README.md) | `贪心`,`字符串`,`动态规划` | 困难 | 第 453 场周赛 |
+| 3580 | [寻找持续进步的员工](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README.md) | `数据库` | 中等 | |
## 版权
diff --git a/solution/README_EN.md b/solution/README_EN.md
index 4832ce6e18369..0541b4d5827a5 100644
--- a/solution/README_EN.md
+++ b/solution/README_EN.md
@@ -3579,16 +3579,16 @@ Press Control + F(or Command + F on
| 3568 | [Minimum Moves to Clean the Classroom](/solution/3500-3599/3568.Minimum%20Moves%20to%20Clean%20the%20Classroom/README_EN.md) | `Bit Manipulation`,`Breadth-First Search`,`Array`,`Hash Table`,`Matrix` | Medium | Weekly Contest 452 |
| 3569 | [Maximize Count of Distinct Primes After Split](/solution/3500-3599/3569.Maximize%20Count%20of%20Distinct%20Primes%20After%20Split/README_EN.md) | `Segment Tree`,`Array`,`Math`,`Number Theory` | Hard | Weekly Contest 452 |
| 3570 | [Find Books with No Available Copies](/solution/3500-3599/3570.Find%20Books%20with%20No%20Available%20Copies/README_EN.md) | `Database` | Easy | |
-| 3571 | [Find the Shortest Superstring II](/solution/3500-3599/3571.Find%20the%20Shortest%20Superstring%20II/README_EN.md) | | Easy | 🔒 |
-| 3572 | [Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values](/solution/3500-3599/3572.Maximize%20Y%E2%80%91Sum%20by%20Picking%20a%20Triplet%20of%20Distinct%20X%E2%80%91Values/README_EN.md) | | Medium | Biweekly Contest 158 |
-| 3573 | [Best Time to Buy and Sell Stock V](/solution/3500-3599/3573.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20V/README_EN.md) | | Medium | Biweekly Contest 158 |
-| 3574 | [Maximize Subarray GCD Score](/solution/3500-3599/3574.Maximize%20Subarray%20GCD%20Score/README_EN.md) | | Hard | Biweekly Contest 158 |
-| 3575 | [Maximum Good Subtree Score](/solution/3500-3599/3575.Maximum%20Good%20Subtree%20Score/README_EN.md) | | Hard | Biweekly Contest 158 |
-| 3576 | [Transform Array to All Equal Elements](/solution/3500-3599/3576.Transform%20Array%20to%20All%20Equal%20Elements/README_EN.md) | | Medium | Weekly Contest 453 |
-| 3577 | [Count the Number of Computer Unlocking Permutations](/solution/3500-3599/3577.Count%20the%20Number%20of%20Computer%20Unlocking%20Permutations/README_EN.md) | | Medium | Weekly Contest 453 |
-| 3578 | [Count Partitions With Max-Min Difference at Most K](/solution/3500-3599/3578.Count%20Partitions%20With%20Max-Min%20Difference%20at%20Most%20K/README_EN.md) | | Medium | Weekly Contest 453 |
-| 3579 | [Minimum Steps to Convert String with Operations](/solution/3500-3599/3579.Minimum%20Steps%20to%20Convert%20String%20with%20Operations/README_EN.md) | | Hard | Weekly Contest 453 |
-| 3580 | [Find Consistently Improving Employees](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README_EN.md) | | Medium | |
+| 3571 | [Find the Shortest Superstring II](/solution/3500-3599/3571.Find%20the%20Shortest%20Superstring%20II/README_EN.md) | `String` | Easy | 🔒 |
+| 3572 | [Maximize Y‑Sum by Picking a Triplet of Distinct X‑Values](/solution/3500-3599/3572.Maximize%20Y%E2%80%91Sum%20by%20Picking%20a%20Triplet%20of%20Distinct%20X%E2%80%91Values/README_EN.md) | `Greedy`,`Array`,`Hash Table`,`Sorting`,`Heap (Priority Queue)` | Medium | Biweekly Contest 158 |
+| 3573 | [Best Time to Buy and Sell Stock V](/solution/3500-3599/3573.Best%20Time%20to%20Buy%20and%20Sell%20Stock%20V/README_EN.md) | `Array`,`Dynamic Programming` | Medium | Biweekly Contest 158 |
+| 3574 | [Maximize Subarray GCD Score](/solution/3500-3599/3574.Maximize%20Subarray%20GCD%20Score/README_EN.md) | `Array`,`Math`,`Enumeration`,`Number Theory` | Hard | Biweekly Contest 158 |
+| 3575 | [Maximum Good Subtree Score](/solution/3500-3599/3575.Maximum%20Good%20Subtree%20Score/README_EN.md) | `Bit Manipulation`,`Tree`,`Depth-First Search`,`Array`,`Dynamic Programming`,`Bitmask` | Hard | Biweekly Contest 158 |
+| 3576 | [Transform Array to All Equal Elements](/solution/3500-3599/3576.Transform%20Array%20to%20All%20Equal%20Elements/README_EN.md) | `Greedy`,`Array` | Medium | Weekly Contest 453 |
+| 3577 | [Count the Number of Computer Unlocking Permutations](/solution/3500-3599/3577.Count%20the%20Number%20of%20Computer%20Unlocking%20Permutations/README_EN.md) | `Brainteaser`,`Array`,`Math`,`Combinatorics` | Medium | Weekly Contest 453 |
+| 3578 | [Count Partitions With Max-Min Difference at Most K](/solution/3500-3599/3578.Count%20Partitions%20With%20Max-Min%20Difference%20at%20Most%20K/README_EN.md) | `Queue`,`Array`,`Dynamic Programming`,`Prefix Sum`,`Sliding Window`,`Monotonic Queue` | Medium | Weekly Contest 453 |
+| 3579 | [Minimum Steps to Convert String with Operations](/solution/3500-3599/3579.Minimum%20Steps%20to%20Convert%20String%20with%20Operations/README_EN.md) | `Greedy`,`String`,`Dynamic Programming` | Hard | Weekly Contest 453 |
+| 3580 | [Find Consistently Improving Employees](/solution/3500-3599/3580.Find%20Consistently%20Improving%20Employees/README_EN.md) | `Database` | Medium | |
## Copyright