1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-25 17:50:26 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/好友申请 II :谁有最多的好友 [friend-requests-ii-who-has-the-most-friends].html
2023-12-09 18:53:53 +08:00

54 lines
1.6 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>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>