1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-14 20:01:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2023-12-09 18:53:53 +08:00
parent c9b1bf36a8
commit 9bc4722a45
349 changed files with 15897 additions and 0 deletions

View File

@@ -0,0 +1,53 @@
<p><code>RequestAccepted</code> 表:</p>
<div class="original__bRMd">
<div>
<pre>
+----------------+---------+
| Column Name | Type |
+----------------+---------+
| requester_id | int |
| accepter_id | int |
| accept_date | date |
+----------------+---------+
(requester_id, accepter_id) 是这张表的主键(具有唯一值的列的组合)。
这张表包含发送好友请求的人的 ID ,接收好友请求的人的 ID ,以及好友请求通过的日期。
</pre>
<p>&nbsp;</p>
<p>编写解决方案,找出拥有最多的好友的人和他拥有的好友数目。</p>
<p>生成的测试用例保证拥有最多好友数目的只有 1 个人。</p>
<p>查询结果格式如下例所示。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>
RequestAccepted 表:
+--------------+-------------+-------------+
| requester_id | accepter_id | accept_date |
+--------------+-------------+-------------+
| 1 | 2 | 2016/06/03 |
| 1 | 3 | 2016/06/08 |
| 2 | 3 | 2016/06/08 |
| 3 | 4 | 2016/06/09 |
+--------------+-------------+-------------+
<strong>输出:</strong>
+----+-----+
| id | num |
+----+-----+
| 3 | 3 |
+----+-----+
<strong>解释:</strong>
编号为 3 的人是编号为 1 2 和 4 的人的好友,所以他总共有 3 个好友,比其他人都多。</pre>
<p>&nbsp;</p>
<p><strong>进阶:</strong>在真实世界里,可能会有多个人拥有好友数相同且最多,你能找到所有这些人吗?</p>
</div>
</div>