mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-05 23:41:41 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>有 <code>n</code> 个朋友在举办一个派对,这些朋友从 <code>0</code> 到 <code>n - 1</code> 编号。派对里有 <strong>无数</strong> 张椅子,编号为 <code>0</code> 到 <code>infinity</code> 。当一个朋友到达派对时,他会占据 <strong>编号最小</strong> 且未被占据的椅子。</p>\n\n<ul>\n\t<li>比方说,当一个朋友到达时,如果椅子 <code>0</code> ,<code>1</code> 和 <code>5</code> 被占据了,那么他会占据 <code>2</code> 号椅子。</li>\n</ul>\n\n<p>当一个朋友离开派对时,他的椅子会立刻变成未占据状态。如果同一时刻有另一个朋友到达,可以立即占据这张椅子。</p>\n\n<p>给你一个下标从 <strong>0</strong> 开始的二维整数数组 <code>times</code> ,其中 <code>times[i] = [arrival<sub>i</sub>, leaving<sub>i</sub>]</code> 表示第 <code>i</code> 个朋友到达和离开的时刻,同时给你一个整数 <code>targetFriend</code> 。所有到达时间 <strong>互不相同</strong> 。</p>\n\n<p>请你返回编号为 <code>targetFriend</code> 的朋友占据的 <strong>椅子编号</strong> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre><b>输入:</b>times = [[1,4],[2,3],[4,6]], targetFriend = 1\n<b>输出:</b>1\n<b>解释:</b>\n- 朋友 0 时刻 1 到达,占据椅子 0 。\n- 朋友 1 时刻 2 到达,占据椅子 1 。\n- 朋友 1 时刻 3 离开,椅子 1 变成未占据。\n- 朋友 0 时刻 4 离开,椅子 0 变成未占据。\n- 朋友 2 时刻 4 到达,占据椅子 0 。\n朋友 1 占据椅子 1 ,所以返回 1 。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre><b>输入:</b>times = [[3,10],[1,5],[2,6]], targetFriend = 0\n<b>输出:</b>2\n<b>解释:</b>\n- 朋友 1 时刻 1 到达,占据椅子 0 。\n- 朋友 2 时刻 2 到达,占据椅子 1 。\n- 朋友 0 时刻 3 到达,占据椅子 2 。\n- 朋友 1 时刻 5 离开,椅子 0 变成未占据。\n- 朋友 2 时刻 6 离开,椅子 1 变成未占据。\n- 朋友 0 时刻 10 离开,椅子 2 变成未占据。\n朋友 0 占据椅子 2 ,所以返回 2 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == times.length</code></li>\n\t<li><code>2 <= n <= 10<sup>4</sup></code></li>\n\t<li><code>times[i].length == 2</code></li>\n\t<li><code>1 <= arrival<sub>i</sub> < leaving<sub>i</sub> <= 10<sup>5</sup></code></li>\n\t<li><code>0 <= targetFriend <= n - 1</code></li>\n\t<li>每个 <code>arrival<sub>i</sub></code> 时刻 <strong>互不相同</strong> 。</li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 21,
|
||||
"likes": 22,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -137,7 +137,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"3.6K\", \"totalSubmission\": \"8.8K\", \"totalAcceptedRaw\": 3554, \"totalSubmissionRaw\": 8835, \"acRate\": \"40.2%\"}",
|
||||
"stats": "{\"totalAccepted\": \"3.7K\", \"totalSubmission\": \"9K\", \"totalAcceptedRaw\": 3658, \"totalSubmissionRaw\": 9037, \"acRate\": \"40.5%\"}",
|
||||
"hints": [
|
||||
"Sort times by arrival time.",
|
||||
"for each arrival_i find the smallest unoccupied chair and mark it as occupied until leaving_i."
|
||||
|
Reference in New Issue
Block a user