1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-10-21 13:06:47 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2025-09-29 14:43:44 +08:00
parent 2862a227c4
commit 13f2098086
4409 changed files with 168933 additions and 166256 deletions

View File

@@ -12,12 +12,12 @@
"translatedContent": "<p>表: <code>Activity</code></p>\n\n<pre>\n+----------------+---------+\n| Column Name | Type |\n+----------------+---------+\n| machine_id | int |\n| process_id | int |\n| activity_type | enum |\n| timestamp | float |\n+----------------+---------+\n该表展示了一家工厂网站的用户活动。\n(machine_id, process_id, activity_type) 是当前表的主键(具有唯一值的列的组合)。\nmachine_id 是一台机器的ID号。\nprocess_id 是运行在各机器上的进程ID号。\nactivity_type 是枚举类型 ('start', 'end')。\ntimestamp 是浮点类型,代表当前时间(以秒为单位)。\n'start' 代表该进程在这台机器上的开始运行时间戳 , 'end' 代表该进程在这台机器上的终止运行时间戳。\n同一台机器同一个进程都有一对开始时间戳和结束时间戳而且开始时间戳永远在结束时间戳前面。</pre>\n\n<p>&nbsp;</p>\n\n<p>现在有一个工厂网站由几台机器运行,每台机器上运行着 <strong>相同数量的进程</strong> 。编写解决方案,计算每台机器各自完成一个进程任务的平均耗时。</p>\n\n<p>完成一个进程任务的时间指进程的<code>'end' 时间戳</code> 减去&nbsp;<code>'start' 时间戳</code>。平均耗时通过计算每台机器上所有进程任务的总耗费时间除以机器上的总进程数量获得。</p>\n\n<p>结果表必须包含<code>machine_id机器ID</code> 和对应的&nbsp;<strong>average time平均耗时</strong>&nbsp;别名&nbsp;<code>processing_time</code>,且<strong>四舍五入保留3位小数。</strong></p>\n\n<p>以 <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| machine_id | process_id | activity_type | timestamp |\n+------------+------------+---------------+-----------+\n| 0 | 0 | start | 0.712 |\n| 0 | 0 | end | 1.520 |\n| 0 | 1 | start | 3.140 |\n| 0 | 1 | end | 4.120 |\n| 1 | 0 | start | 0.550 |\n| 1 | 0 | end | 1.550 |\n| 1 | 1 | start | 0.430 |\n| 1 | 1 | end | 1.420 |\n| 2 | 0 | start | 4.100 |\n| 2 | 0 | end | 4.512 |\n| 2 | 1 | start | 2.500 |\n| 2 | 1 | end | 5.000 |\n+------------+------------+---------------+-----------+\n<strong>输出:</strong>\n+------------+-----------------+\n| machine_id | processing_time |\n+------------+-----------------+\n| 0 | 0.894 |\n| 1 | 0.995 |\n| 2 | 1.456 |\n+------------+-----------------+\n<strong>解释:</strong>\n一共有3台机器,每台机器运行着两个进程.\n机器 0 的平均耗时: ((1.520 - 0.712) + (4.120 - 3.140)) / 2 = 0.894\n机器 1 的平均耗时: ((1.550 - 0.550) + (1.420 - 0.430)) / 2 = 0.995\n机器 2 的平均耗时: ((4.512 - 4.100) + (5.000 - 2.500)) / 2 = 1.456</pre>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 196,
"likes": 259,
"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, \"cangjie\": false}",
"langToValidPlayground": "{\"cpp\": false, \"java\": false, \"python3\": false, \"python\": false, \"javascript\": false, \"typescript\": false, \"csharp\": false, \"c\": false, \"golang\": false, \"kotlin\": false, \"swift\": false, \"rust\": false, \"ruby\": false, \"php\": false, \"dart\": false, \"scala\": false, \"elixir\": false, \"erlang\": false, \"racket\": false, \"cangjie\": false, \"bash\": false, \"html\": false, \"pythonml\": false, \"react\": false, \"vanillajs\": false, \"mysql\": false, \"mssql\": false, \"postgresql\": false, \"oraclesql\": false, \"pythondata\": false}",
"topicTags": [
{
"name": "Database",
@@ -40,6 +40,12 @@
"code": "/* Write your T-SQL query statement below */",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
},
{
"lang": "Oracle",
"langSlug": "oraclesql",
@@ -51,15 +57,9 @@
"langSlug": "pythondata",
"code": "import pandas as pd\n\ndef get_average_time(activity: pd.DataFrame) -> pd.DataFrame:\n ",
"__typename": "CodeSnippetNode"
},
{
"lang": "PostgreSQL",
"langSlug": "postgresql",
"code": "-- Write your PostgreSQL query statement below",
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"69.9K\", \"totalSubmission\": \"98.2K\", \"totalAcceptedRaw\": 69897, \"totalSubmissionRaw\": 98152, \"acRate\": \"71.2%\"}",
"stats": "{\"totalAccepted\": \"100.6K\", \"totalSubmission\": \"141.6K\", \"totalAcceptedRaw\": 100575, \"totalSubmissionRaw\": 141648, \"acRate\": \"71.0%\"}",
"hints": [],
"solution": null,
"status": null,