1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-04 06:51:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
Files
leetcode-problemset/leetcode-cn/problem (Chinese)/查找超预订员工 [find-overbooked-employees].html
2025-07-17 00:14:36 +08:00

126 lines
5.2 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>表:<code>employees</code></p>
<pre>
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| employee_id | int |
| employee_name | varchar |
| department | varchar |
+---------------+---------+
employee_id 是这张表的唯一主键。
每一行包含一个员工和他们部门的信息。
</pre>
<p>表:<code>meetings</code></p>
<pre>
+---------------+---------+
| Column Name | Type |
+---------------+---------+
| meeting_id | int |
| employee_id | int |
| meeting_date | date |
| meeting_type | varchar |
| duration_hours| decimal |
+---------------+---------+
meeting_id 是这张表的唯一主键。
每一行表示一位员工参加的会议。meeting_type 可以是 'Team''Client' 或 'Training'。
</pre>
<p>编写一个解决方案来查找会议密集型的员工&nbsp;-&nbsp; 在任何给定周内,花费超过 <code>50%</code> 工作时间在会议上的员工。</p>
<ul>
<li>假定一个标准工作周是&nbsp;<code>40</code><strong> 小时</strong></li>
<li>计算每位员工 <strong>每周</strong><strong>周一至周日</strong>)的 <strong>总会议小时数</strong></li>
<li>员工如果每周会议时间超过 <code>20</code> 小时(<code>40</code> 小时工作时间的 <code>50%</code>),则被视为会议密集型。</li>
<li>统计每位员工有多少周是会议密集周</li>
<li><strong>仅查找 至少</strong> <code>2</code> 周会议密集的员工</li>
</ul>
<p>返回结果表按会议密集周的数量降序排列,然后按员工姓名升序排列。结果格式如下所示。</p>
<p>&nbsp;</p>
<p><strong class="example">示例:</strong></p>
<div class="example-block">
<p><strong>Input:</strong></p>
<p>employees 表:</p>
<pre class="example-io">
+-------------+----------------+-------------+
| employee_id | employee_name | department |
+-------------+----------------+-------------+
| 1 | Alice Johnson | Engineering |
| 2 | Bob Smith | Marketing |
| 3 | Carol Davis | Sales |
| 4 | David Wilson | Engineering |
| 5 | Emma Brown | HR |
+-------------+----------------+-------------+
</pre>
<p>meetings 表:</p>
<pre class="example-io">
+------------+-------------+--------------+--------------+----------------+
| meeting_id | employee_id | meeting_date | meeting_type | duration_hours |
+------------+-------------+--------------+--------------+----------------+
| 1 | 1 | 2023-06-05 | Team | 8.0 |
| 2 | 1 | 2023-06-06 | Client | 6.0 |
| 3 | 1 | 2023-06-07 | Training | 7.0 |
| 4 | 1 | 2023-06-12 | Team | 12.0 |
| 5 | 1 | 2023-06-13 | Client | 9.0 |
| 6 | 2 | 2023-06-05 | Team | 15.0 |
| 7 | 2 | 2023-06-06 | Client | 8.0 |
| 8 | 2 | 2023-06-12 | Training | 10.0 |
| 9 | 3 | 2023-06-05 | Team | 4.0 |
| 10 | 3 | 2023-06-06 | Client | 3.0 |
| 11 | 4 | 2023-06-05 | Team | 25.0 |
| 12 | 4 | 2023-06-19 | Client | 22.0 |
| 13 | 5 | 2023-06-05 | Training | 2.0 |
+------------+-------------+--------------+--------------+----------------+
</pre>
<p><strong>输出:</strong></p>
<pre class="example-io">
+-------------+----------------+-------------+---------------------+
| employee_id | employee_name | department | meeting_heavy_weeks |
+-------------+----------------+-------------+---------------------+
| 1 | Alice Johnson | Engineering | 2 |
| 4 | David Wilson | Engineering | 2 |
+-------------+----------------+-------------+---------------------+
</pre>
<p><strong>解释:</strong></p>
<ul>
<li><strong>Alice Johnson (employee_id = 1):</strong>
<ul>
<li>6 月 5 日至 11 日2023-06-05 至 2023-06-118.0 + 6.0 + 7.0 = 21.0 小时(&gt; 20 小时)</li>
<li>6 月 12&nbsp;日至 18&nbsp;2023-06-12 至 2023-06-18: 12.0 + 9.0 = 21.0 小时(&gt; 20 小时)</li>
<li>2 周会议密集</li>
</ul>
</li>
<li><strong>David Wilson (employee_id = 4):</strong>
<ul>
<li>6 月 5 日至 11 日25.0 小时(&gt; 20 小时)</li>
<li>6 月 19&nbsp;日至 25&nbsp;22.0 小时(&gt; 20 小时)</li>
<li>2 周会议密集</li>
</ul>
</li>
<li><strong>未包含的员工:</strong>
<ul>
<li>Bob Smithemployee_id = 26 月 5 日至 11 日15.0 + 8.0 = 23.0 小时(&gt; 206 月 12&nbsp;日至 18&nbsp;10.0 小时(&lt; 20。只有 1 个会议密集周。</li>
<li>Carol Davisemployee_id = 36 月 5 日至 11 日4.0 + 3.0 = 7.0 小时(&lt; 20。没有会议密集周。</li>
<li>Emma Brownemployee_id = 56 月 5 日至 11 日2.0 小时(&lt; 20。没有会议密集周。</li>
</ul>
</li>
</ul>
<p>结果表按 meeting_heavy_weeks 降序排列,然后按员工姓名升序排列。</p>
</div>