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-cn/originData/game-play-analysis-iv.json
2023-12-09 19:57:46 +08:00

92 lines
10 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": "1182",
"questionFrontendId": "550",
"categoryTitle": "Database",
"boundTopicId": 11038,
"title": "Game Play Analysis IV",
"titleSlug": "game-play-analysis-iv",
"content": "<p>Table: <code>Activity</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| player_id | int |\n| device_id | int |\n| event_date | date |\n| games_played | int |\n+--------------+---------+\n(player_id, event_date) is the primary key (combination of columns with unique values) of this table.\nThis table shows the activity of players of some games.\nEach row is a record of a player who logged in and played a number of games (possibly 0) before logging out on someday using some device.\n</pre>\n\n<p>&nbsp;</p>\n\n<p>Write a&nbsp;solution&nbsp;to report the <strong>fraction</strong> of players that logged in again on the day after the day they first logged in, <strong>rounded to 2 decimal places</strong>. In other words, you need to count the number of players that logged in for at least two consecutive days starting from their first login date, then divide that number by the total number of players.</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> \nActivity table:\n+-----------+-----------+------------+--------------+\n| player_id | device_id | event_date | games_played |\n+-----------+-----------+------------+--------------+\n| 1 | 2 | 2016-03-01 | 5 |\n| 1 | 2 | 2016-03-02 | 6 |\n| 2 | 3 | 2017-06-25 | 1 |\n| 3 | 1 | 2016-03-02 | 0 |\n| 3 | 4 | 2018-07-03 | 5 |\n+-----------+-----------+------------+--------------+\n<strong>Output:</strong> \n+-----------+\n| fraction |\n+-----------+\n| 0.33 |\n+-----------+\n<strong>Explanation:</strong> \nOnly the player with id 1 logged back in after the first day he had logged in so the answer is 1/3 = 0.33\n</pre>\n",
"translatedTitle": "游戏玩法分析 IV",
"translatedContent": "<p>Table:&nbsp;<code>Activity</code></p>\n\n<pre>\n+--------------+---------+\n| Column Name | Type |\n+--------------+---------+\n| player_id | int |\n| device_id | int |\n| event_date | date |\n| games_played | int |\n+--------------+---------+\nplayer_idevent_date是此表的主键具有唯一值的列的组合。\n这张表显示了某些游戏的玩家的活动情况。\n每一行是一个玩家的记录他在某一天使用某个设备注销之前登录并玩了很多游戏可能是 0。\n</pre>\n\n<p>&nbsp;</p>\n\n<p>编写解决方案,报告在首次登录的第二天再次登录的玩家的 <strong>比率</strong><strong>四舍五入到小数点后两位</strong>。换句话说,你需要计算从首次登录日期开始至少连续两天登录的玩家的数量,然后除以玩家总数。</p>\n\n<p>结果格式如下所示:</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>\nActivity table:\n+-----------+-----------+------------+--------------+\n| player_id | device_id | event_date | games_played |\n+-----------+-----------+------------+--------------+\n| 1 | 2 | 2016-03-01 | 5 |\n| 1 | 2 | 2016-03-02 | 6 |\n| 2 | 3 | 2017-06-25 | 1 |\n| 3 | 1 | 2016-03-02 | 0 |\n| 3 | 4 | 2018-07-03 | 5 |\n+-----------+-----------+------------+--------------+\n<strong>输出:</strong>\n+-----------+\n| fraction |\n+-----------+\n| 0.33 |\n+-----------+\n<strong>解释:</strong>\n只有 ID 为 1 的玩家在第一天登录后才重新登录,所以答案是 1/3 = 0.33\n</pre>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 185,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[{\"title\": \"Game Play Analysis III\", \"titleSlug\": \"game-play-analysis-iii\", \"difficulty\": \"Medium\", \"translatedTitle\": \"\\u6e38\\u620f\\u73a9\\u6cd5\\u5206\\u6790 III\", \"isPaidOnly\": true}, {\"title\": \"Game Play Analysis V\", \"titleSlug\": \"game-play-analysis-v\", \"difficulty\": \"Hard\", \"translatedTitle\": \"\\u6e38\\u620f\\u73a9\\u6cd5\\u5206\\u6790 V\", \"isPaidOnly\": true}]",
"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 gameplay_analysis(activity: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"45.5K\", \"totalSubmission\": \"110K\", \"totalAcceptedRaw\": 45536, \"totalSubmissionRaw\": 110004, \"acRate\": \"41.4%\"}",
"hints": [],
"solution": null,
"status": null,
"sampleTestCase": "{\"headers\":{\"Activity\":[\"player_id\",\"device_id\",\"event_date\",\"games_played\"]},\"rows\":{\"Activity\":[[1,2,\"2016-03-01\",5],[1,2,\"2016-03-02\",6],[2,3,\"2017-06-25\",1],[3,1,\"2016-03-02\",0],[3,4,\"2018-07-03\",5]]}}",
"metaData": "{\"mysql\":[\"Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)\"],\"mssql\":[\"Create table Activity (player_id int, device_id int, event_date date, games_played int)\"],\"oraclesql\":[\"Create table Activity (player_id int, device_id int, event_date date, games_played int)\",\"ALTER SESSION SET nls_date_format='YYYY-MM-DD'\"],\"database\":true,\"name\":\"gameplay_analysis\",\"pythondata\":[\"Activity = pd.DataFrame([], columns=['player_id', 'device_id', 'event_date', 'games_played']).astype({'player_id':'Int64', 'device_id':'Int64', 'event_date':'datetime64[ns]', 'games_played':'Int64'})\"],\"postgresql\":[\"\\nCreate table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)\"],\"database_schema\":{\"Activity\":{\"player_id\":\"INT\",\"device_id\":\"INT\",\"event_date\":\"DATE\",\"games_played\":\"INT\"}}}",
"judgerAvailable": true,
"judgeType": "large",
"mysqlSchemas": [
"Create table If Not Exists Activity (player_id int, device_id int, event_date date, games_played int)",
"Truncate table Activity",
"insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-01', '5')",
"insert into Activity (player_id, device_id, event_date, games_played) values ('1', '2', '2016-03-02', '6')",
"insert into Activity (player_id, device_id, event_date, games_played) values ('2', '3', '2017-06-25', '1')",
"insert into Activity (player_id, device_id, event_date, games_played) values ('3', '1', '2016-03-02', '0')",
"insert into Activity (player_id, device_id, event_date, games_played) values ('3', '4', '2018-07-03', '5')"
],
"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\":{\"Activity\":[\"player_id\",\"device_id\",\"event_date\",\"games_played\"]},\"rows\":{\"Activity\":[[1,2,\"2016-03-01\",5],[1,2,\"2016-03-02\",6],[2,3,\"2017-06-25\",1],[3,1,\"2016-03-02\",0],[3,4,\"2018-07-03\",5]]}}",
"__typename": "QuestionNode"
}
}
}