1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-11 02:58:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/originData/find-followers-count.json

91 lines
7.8 KiB
JSON
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.

{
"data": {
"question": {
"questionId": "1877",
"questionFrontendId": "1729",
"categoryTitle": "Database",
"boundTopicId": 564380,
"title": "Find Followers Count",
"titleSlug": "find-followers-count",
"content": "<p>Table: <code>Followers</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| user_id | int |\n| follower_id | int |\n+-------------+------+\n(user_id, follower_id) is the primary key (combination of columns with unique values) for this table.\nThis table contains the IDs of a user and a follower in a social media app where the follower follows the user.</pre>\n\n<p>&nbsp;</p>\n\n<p>Write a solution that will, for each user, return the number of followers.</p>\n\n<p>Return the result table ordered by <code>user_id</code> in ascending order.</p>\n\n<p>The&nbsp;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> \nFollowers table:\n+---------+-------------+\n| user_id | follower_id |\n+---------+-------------+\n| 0 | 1 |\n| 1 | 0 |\n| 2 | 0 |\n| 2 | 1 |\n+---------+-------------+\n<strong>Output:</strong> \n+---------+----------------+\n| user_id | followers_count|\n+---------+----------------+\n| 0 | 1 |\n| 1 | 1 |\n| 2 | 2 |\n+---------+----------------+\n<strong>Explanation:</strong> \nThe followers of 0 are {1}\nThe followers of 1 are {0}\nThe followers of 2 are {0,1}\n</pre>\n",
"translatedTitle": "求关注者的数量",
"translatedContent": "<p>表:&nbsp;<code>Followers</code></p>\n\n<pre>\n+-------------+------+\n| Column Name | Type |\n+-------------+------+\n| user_id | int |\n| follower_id | int |\n+-------------+------+\n(user_id, follower_id) 是这个表的主键(具有唯一值的列的组合)。\n该表包含一个关注关系中关注者和用户的编号其中关注者关注用户。</pre>\n\n<p>&nbsp;</p>\n\n<p>编写解决方案,对于每一个用户,返回该用户的关注者数量。</p>\n\n<p>按&nbsp;<code>user_id</code>&nbsp;的顺序返回结果表。</p>\n\n<p>查询结果的格式如下示例所示。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>\nFollowers 表:\n+---------+-------------+\n| user_id | follower_id |\n+---------+-------------+\n| 0 | 1 |\n| 1 | 0 |\n| 2 | 0 |\n| 2 | 1 |\n+---------+-------------+\n<strong>输出:</strong>\n+---------+----------------+\n| user_id | followers_count|\n+---------+----------------+\n| 0 | 1 |\n| 1 | 1 |\n| 2 | 2 |\n+---------+----------------+\n<strong>解释:</strong>\n0 的关注者有 {1}\n1 的关注者有 {0}\n2 的关注者有 {0,1}</pre>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 48,
"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 count_followers(followers: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"40.1K\", \"totalSubmission\": \"66.5K\", \"totalAcceptedRaw\": 40136, \"totalSubmissionRaw\": 66502, \"acRate\": \"60.4%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Followers\":[\"user_id\",\"follower_id\"]},\"rows\":{\"Followers\":[[\"0\",\"1\"],[\"1\",\"0\"],[\"2\",\"0\"],[\"2\",\"1\"]]}}",
"metaData": "{\"mysql\":[\"Create table If Not Exists Followers(user_id int, follower_id int)\"],\"mssql\":[\"Create table Followers(user_id int, follower_id int)\"],\"oraclesql\":[\"Create table Followers(user_id int, follower_id int)\"],\"database\":true,\"name\":\"count_followers\",\"pythondata\":[\"Followers = pd.DataFrame([], columns=['user_id', 'follower_id']).astype({'user_id':'Int64', 'follower_id':'Int64'})\"],\"postgresql\":[\"\\nCreate table If Not Exists Followers(user_id int, follower_id int)\"],\"database_schema\":{\"Followers\":{\"user_id\":\"INT\",\"follower_id\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Followers(user_id int, follower_id int)",
"Truncate table Followers",
"insert into Followers (user_id, follower_id) values ('0', '1')",
"insert into Followers (user_id, follower_id) values ('1', '0')",
"insert into Followers (user_id, follower_id) values ('2', '0')",
"insert into Followers (user_id, follower_id) values ('2', '1')"
],
"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\":{\"Followers\":[\"user_id\",\"follower_id\"]},\"rows\":{\"Followers\":[[\"0\",\"1\"],[\"1\",\"0\"],[\"2\",\"0\"],[\"2\",\"1\"]]}}",
"__typename": "QuestionNode"
}
}
}