1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode/originData/friend-requests-ii-who-has-the-most-friends.json
2023-12-09 19:57:46 +08:00

90 lines
7.2 KiB
JSON

{
"data": {
"question": {
"questionId": "602",
"questionFrontendId": "602",
"boundTopicId": null,
"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>&nbsp;</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>&nbsp;</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>&nbsp;</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": null,
"translatedContent": null,
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 538,
"dislikes": 96,
"isLiked": null,
"similarQuestions": "[]",
"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\"]]}}",
"categoryTitle": "Database",
"contributors": [],
"topicTags": [
{
"name": "Database",
"slug": "database",
"translatedName": null,
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
"codeSnippets": [
{
"lang": "MySQL",
"langSlug": "mysql",
"code": "# Write your MySQL query statement below\n",
"__typename": "CodeSnippetNode"
},
{
"lang": "MS SQL Server",
"langSlug": "mssql",
"code": "/* Write your T-SQL query statement below */\n",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
"code": "/* Write your PL/SQL query statement below */\n",
"__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\n",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"91.7K\", \"totalSubmission\": \"161.4K\", \"totalAcceptedRaw\": 91735, \"totalSubmissionRaw\": 161408, \"acRate\": \"56.8%\"}",
"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,
"enableTestMode": false,
"enableDebugger": false,
"envInfo": "{\"mysql\": [\"MySQL\", \"<p><code>MySQL 8.0</code>.</p>\"], \"mssql\": [\"MS SQL Server\", \"<p><code>mssql server 2019</code>.</p>\"], \"oraclesql\": [\"Oracle\", \"<p><code>Oracle Sql 11.2</code>.</p>\"], \"pythondata\": [\"Pandas\", \"<p>Python 3.10 with Pandas 2.0.2 and NumPy 1.25.0</p>\"], \"postgresql\": [\"PostgreSQL\", \"<p>PostgreSQL 16</p>\"]}",
"libraryUrl": null,
"adminUrl": null,
"challengeQuestion": null,
"__typename": "QuestionNode"
}
}
}