1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 03:11:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-06-18 01:10:28 +08:00
parent e4efda71b2
commit 1e59635fae
68 changed files with 17746 additions and 9789 deletions

View File

@@ -0,0 +1,138 @@
<p>表:<code>employees</code></p>
<pre>
+-------------+---------+
| Column Name | Type |
+-------------+---------+
| employee_id | int |
| name | varchar |
+-------------+---------+
employee_id 是这张表的唯一主键。
每一行包含一名员工的信息。
</pre>
<p>表:<code>performance_reviews</code></p>
<pre>
+-------------+------+
| Column Name | Type |
+-------------+------+
| review_id | int |
| employee_id | int |
| review_date | date |
| rating | int |
+-------------+------+
review_id 是这张表的唯一主键。
每一行表示一名员工的绩效评估。评分在 1-5 的范围内5分代表优秀1分代表较差。
</pre>
<p>编写一个解决方案,以找到在过去三次评估中持续提高绩效的员工。</p>
<ul>
<li>员工 <strong>至少需要</strong> <code>3</code>&nbsp;<strong>次评估&nbsp;</strong>才能被考虑</li>
<li>员工过去的&nbsp;<code>3</code> 次评估,评分必须&nbsp;<strong>严格递增</strong>(每次评价都比上一次好)</li>
<li>根据 <code>review_date</code> 为每位员工分析最近的 <code>3</code> 次评估</li>
<li><strong>进步分数</strong> 为最后 <code>3</code> 次评估中最后一次评分与最早一次评分之间的差值</li>
</ul>
<p>返回结果表以<em>&nbsp;</em><strong>进步分数 降序</strong>&nbsp;排序,然后以&nbsp;<strong>名字</strong>&nbsp;<strong>升序</strong>&nbsp;排序。</p>
<p>结果格式如下所示。</p>
<p>&nbsp;</p>
<p><strong class="example">示例:</strong></p>
<div class="example-block">
<p><strong>输入:</strong></p>
<p>employees 表:</p>
<pre class="example-io">
+-------------+----------------+
| employee_id | name |
+-------------+----------------+
| 1 | Alice Johnson |
| 2 | Bob Smith |
| 3 | Carol Davis |
| 4 | David Wilson |
| 5 | Emma Brown |
+-------------+----------------+
</pre>
<p>performance_reviews 表:</p>
<pre class="example-io">
+-----------+-------------+-------------+--------+
| review_id | employee_id | review_date | rating |
+-----------+-------------+-------------+--------+
| 1 | 1 | 2023-01-15 | 2 |
| 2 | 1 | 2023-04-15 | 3 |
| 3 | 1 | 2023-07-15 | 4 |
| 4 | 1 | 2023-10-15 | 5 |
| 5 | 2 | 2023-02-01 | 3 |
| 6 | 2 | 2023-05-01 | 2 |
| 7 | 2 | 2023-08-01 | 4 |
| 8 | 2 | 2023-11-01 | 5 |
| 9 | 3 | 2023-03-10 | 1 |
| 10 | 3 | 2023-06-10 | 2 |
| 11 | 3 | 2023-09-10 | 3 |
| 12 | 3 | 2023-12-10 | 4 |
| 13 | 4 | 2023-01-20 | 4 |
| 14 | 4 | 2023-04-20 | 4 |
| 15 | 4 | 2023-07-20 | 4 |
| 16 | 5 | 2023-02-15 | 3 |
| 17 | 5 | 2023-05-15 | 2 |
+-----------+-------------+-------------+--------+
</pre>
<p><strong>输出:</strong></p>
<pre class="example-io">
+-------------+----------------+-------------------+
| employee_id | name | improvement_score |
+-------------+----------------+-------------------+
| 2 | Bob Smith | 3 |
| 1 | Alice Johnson | 2 |
| 3 | Carol Davis | 2 |
+-------------+----------------+-------------------+
</pre>
<p><strong>解释:</strong></p>
<ul>
<li><strong>Alice Johnson (employee_id = 1)</strong>
<ul>
<li>有 4 次评估分数2, 3, 4, 5</li>
<li>最后 3 次评估按日期2023-04-15 (3), 2023-07-15 (4), 2023-10-15 (5)</li>
<li>评分严格递增3 → 4 → 5</li>
<li>进步分数5 - 3 = 2</li>
</ul>
</li>
<li><strong>Carol Davis (employee_id = 3)</strong>
<ul>
<li>有 4 次评估分数1, 2, 3, 4</li>
<li>最后 3 次评估按日期2023-06-10 (2)2023-09-10 (3)2023-12-10 (4)</li>
<li>评分严格递增2 → 3 → 4</li>
<li>进步分数4 - 2 = 2</li>
</ul>
</li>
<li><strong>Bob Smith (employee_id = 2)</strong>
<ul>
<li>有 4 次评估分数3245</li>
<li>最后 3 次评估按日期2023-05-01 (2)2023-08-01 (4)2023-11-01 (5)</li>
<li>评分严格递增2 → 4 → 5</li>
<li>进步分数5 - 2 = 3</li>
</ul>
</li>
<li><strong>未包含的员工:</strong>
<ul>
<li>David Wilson (employee_id = 4):之前 3 次评估都是 4 分(没有进步)</li>
<li>Emma Brown (employee_id = 5):只有 2 次评估(需要至少 3 次)</li>
</ul>
</li>
</ul>
<p>输出表以 improvement_score 降序排序,然后以 name 升序排序。</p>
</div>