mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-01-10 18:48:13 +08:00
93 lines
9.4 KiB
JSON
93 lines
9.4 KiB
JSON
{
|
||
"data": {
|
||
"question": {
|
||
"questionId": "602",
|
||
"questionFrontendId": "602",
|
||
"categoryTitle": "Database",
|
||
"boundTopicId": 2640,
|
||
"title": "Friend Requests II: Who Has the Most Friends",
|
||
"titleSlug": "friend-requests-ii-who-has-the-most-friends",
|
||
"content": "<p>Table: <code>RequestAccepted</code></p>\n\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| requester_id | int |\n| accepter_id | int |\n| accept_date | date |\n+----------------+---------+\n(requester_id, accepter_id) is the primary key (combination of columns with unique values) for this table.\nThis table contains the ID of the user who sent the request, the ID of the user who received the request, and the date when the request was accepted.\n</pre>\n\n<p> </p>\n\n<p>Write a solution to find the people who have the most friends and the most friends number.</p>\n\n<p>The test cases are generated so that only one person has the most friends.</p>\n\n<p>The result format is in the following example.</p>\n\n<p> </p>\n<p><strong class=\"example\">Example 1:</strong></p>\n\n<pre>\n<strong>Input:</strong> \nRequestAccepted table:\n+--------------+-------------+-------------+\n| requester_id | accepter_id | accept_date |\n+--------------+-------------+-------------+\n| 1 | 2 | 2016/06/03 |\n| 1 | 3 | 2016/06/08 |\n| 2 | 3 | 2016/06/08 |\n| 3 | 4 | 2016/06/09 |\n+--------------+-------------+-------------+\n<strong>Output:</strong> \n+----+-----+\n| id | num |\n+----+-----+\n| 3 | 3 |\n+----+-----+\n<strong>Explanation:</strong> \nThe person with id 3 is a friend of people 1, 2, and 4, so he has three friends in total, which is the most number than any others.\n</pre>\n\n<p> </p>\n<p><strong>Follow up:</strong> In the real world, multiple people could have the same most number of friends. Could you find all these people in this case?</p>\n",
|
||
"translatedTitle": "好友申请 II :谁有最多的好友",
|
||
"translatedContent": "<p><code>RequestAccepted</code> 表:</p>\n\n<div class=\"original__bRMd\">\n<div>\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| requester_id | int |\n| accepter_id | int |\n| accept_date | date |\n+----------------+---------+\n(requester_id, accepter_id) 是这张表的主键(具有唯一值的列的组合)。\n这张表包含发送好友请求的人的 ID ,接收好友请求的人的 ID ,以及好友请求通过的日期。\n</pre>\n\n<p> </p>\n\n<p>编写解决方案,找出拥有最多的好友的人和他拥有的好友数目。</p>\n\n<p>生成的测试用例保证拥有最多好友数目的只有 1 个人。</p>\n\n<p>查询结果格式如下例所示。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<strong>输入:</strong>\nRequestAccepted 表:\n+--------------+-------------+-------------+\n| requester_id | accepter_id | accept_date |\n+--------------+-------------+-------------+\n| 1 | 2 | 2016/06/03 |\n| 1 | 3 | 2016/06/08 |\n| 2 | 3 | 2016/06/08 |\n| 3 | 4 | 2016/06/09 |\n+--------------+-------------+-------------+\n<strong>输出:</strong>\n+----+-----+\n| id | num |\n+----+-----+\n| 3 | 3 |\n+----+-----+\n<strong>解释:</strong>\n编号为 3 的人是编号为 1 ,2 和 4 的人的好友,所以他总共有 3 个好友,比其他人都多。</pre>\n\n<p> </p>\n\n<p><strong>进阶:</strong>在真实世界里,可能会有多个人拥有好友数相同且最多,你能找到所有这些人吗?</p>\n</div>\n</div>\n",
|
||
"isPaidOnly": false,
|
||
"difficulty": "Medium",
|
||
"likes": 95,
|
||
"dislikes": 0,
|
||
"isLiked": null,
|
||
"similarQuestions": "[]",
|
||
"contributors": [],
|
||
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python\": false, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"typescript\": false, \"bash\": false, \"php\": false, \"swift\": false, \"kotlin\": false, \"dart\": false, \"golang\": false, \"ruby\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"rust\": false, \"racket\": false, \"erlang\": false, \"elixir\": false, \"pythondata\": false, \"react\": false, \"vanillajs\": false, \"postgresql\": false}",
|
||
"topicTags": [
|
||
{
|
||
"name": "Database",
|
||
"slug": "database",
|
||
"translatedName": "数据库",
|
||
"__typename": "TopicTagNode"
|
||
}
|
||
],
|
||
"companyTagStats": null,
|
||
"codeSnippets": [
|
||
{
|
||
"lang": "MySQL",
|
||
"langSlug": "mysql",
|
||
"code": "# Write your MySQL query statement below",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "MS SQL Server",
|
||
"langSlug": "mssql",
|
||
"code": "/* Write your T-SQL query statement below */",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "Oracle",
|
||
"langSlug": "oraclesql",
|
||
"code": "/* Write your PL/SQL query statement below */",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "Pandas",
|
||
"langSlug": "pythondata",
|
||
"code": "import pandas as pd\n\ndef most_friends(request_accepted: pd.DataFrame) -> pd.DataFrame:\n ",
|
||
"__typename": "CodeSnippetNode"
|
||
},
|
||
{
|
||
"lang": "PostgreSQL",
|
||
"langSlug": "postgresql",
|
||
"code": "-- Write your PostgreSQL query statement below",
|
||
"__typename": "CodeSnippetNode"
|
||
}
|
||
],
|
||
"stats": "{\"totalAccepted\": \"27.7K\", \"totalSubmission\": \"46K\", \"totalAcceptedRaw\": 27691, \"totalSubmissionRaw\": 45987, \"acRate\": \"60.2%\"}",
|
||
"hints": [
|
||
"Being friends is bidirectional. If you accept someone's adding friend request, both you and the other person will have one more friend."
|
||
],
|
||
"solution": null,
|
||
"status": null,
|
||
"sampleTestCase": "{\"headers\":{\"RequestAccepted\":[\"requester_id\",\"accepter_id\",\"accept_date\"]},\"rows\":{\"RequestAccepted\":[[1,2,\"2016/06/03\"],[1,3,\"2016/06/08\"],[2,3,\"2016/06/08\"],[3,4,\"2016/06/09\"]]}}",
|
||
"metaData": "{\"mysql\":[\"Create table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\"],\"mssql\":[\"Create table RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\"],\"oraclesql\":[\"Create table RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\",\"Alter SESSION set NLS_DATE_FORMAT = 'YYYY\\/MM\\/DD'\"],\"database\":true,\"name\":\"most_friends\",\"pythondata\":[\"RequestAccepted = pd.DataFrame([], columns=['requester_id', 'accepter_id', 'accept_date']).astype({'requester_id':'Int64', 'accepter_id':'Int64', 'accept_date':'datetime64[ns]'})\"],\"postgresql\":[\"\\nCreate table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)\"],\"database_schema\":{\"RequestAccepted\":{\"requester_id\":\"INT\",\"accepter_id\":\"INT\",\"accept_date\":\"DATE\"}}}",
|
||
"judgerAvailable": true,
|
||
"judgeType": "large",
|
||
"mysqlSchemas": [
|
||
"Create table If Not Exists RequestAccepted (requester_id int not null, accepter_id int null, accept_date date null)",
|
||
"Truncate table RequestAccepted",
|
||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '2', '2016/06/03')",
|
||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('1', '3', '2016/06/08')",
|
||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('2', '3', '2016/06/08')",
|
||
"insert into RequestAccepted (requester_id, accepter_id, accept_date) values ('3', '4', '2016/06/09')"
|
||
],
|
||
"enableRunCode": true,
|
||
"envInfo": "{\"mysql\":[\"MySQL\",\"<p>\\u7248\\u672c\\uff1a<code>MySQL 8.0<\\/code><\\/p>\"],\"mssql\":[\"MS SQL Server\",\"<p>mssql server 2019.<\\/p>\"],\"oraclesql\":[\"Oracle\",\"<p>Oracle Sql 11.2.<\\/p>\"],\"pythondata\":[\"Pandas\",\"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0<\\/p>\"],\"postgresql\":[\"PostgreSQL\",\"<p>PostgreSQL 16<\\/p>\"]}",
|
||
"book": null,
|
||
"isSubscribed": false,
|
||
"isDailyQuestion": false,
|
||
"dailyRecordStatus": null,
|
||
"editorType": "CKEDITOR",
|
||
"ugcQuestionId": null,
|
||
"style": "LEETCODE",
|
||
"exampleTestcases": "{\"headers\":{\"RequestAccepted\":[\"requester_id\",\"accepter_id\",\"accept_date\"]},\"rows\":{\"RequestAccepted\":[[1,2,\"2016/06/03\"],[1,3,\"2016/06/08\"],[2,3,\"2016/06/08\"],[3,4,\"2016/06/09\"]]}}",
|
||
"__typename": "QuestionNode"
|
||
}
|
||
}
|
||
} |