1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-04 23:11:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-05-02 23:44:12 +08:00
parent 7ea03594b3
commit 2a71c78585
4790 changed files with 11696 additions and 10944 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>有 <code>n</code> 个人前来排队买票,其中第 <code>0</code> 人站在队伍 <strong>最前方</strong> ,第 <code>(n - 1)</code> 人站在队伍 <strong>最后方</strong> 。</p>\n\n<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>tickets</code> ,数组长度为 <code>n</code> ,其中第 <code>i</code> 人想要购买的票数为 <code>tickets[i]</code> 。</p>\n\n<p>每个人买票都需要用掉 <strong>恰好 1 秒</strong> 。一个人 <strong>一次只能买一张票</strong> ,如果需要购买更多票,他必须走到&nbsp; <strong>队尾</strong> 重新排队(<strong>瞬间 </strong>发生,不计时间)。如果一个人没有剩下需要买的票,那他将会 <strong>离开</strong> 队伍。</p>\n\n<p>返回位于位置 <code>k</code>(下标从 <strong>0</strong> 开始)的人完成买票需要的时间(以秒为单位)。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><strong>输入:</strong>tickets = [2,3,2], k = 2\n<strong>输出:</strong>6\n<strong>解释:</strong> \n- 第一轮,队伍中的每个人都买到一张票,队伍变为 [1, 2, 1] 。\n- 第二轮,队伍中的每个都又都买到一张票,队伍变为 [0, 1, 0] 。\n位置 2 的人成功买到 2 张票,用掉 3 + 3 = 6 秒。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><strong>输入:</strong>tickets = [5,1,1,1], k = 0\n<strong>输出:</strong>8\n<strong>解释:</strong>\n- 第一轮,队伍中的每个人都买到一张票,队伍变为 [4, 0, 0, 0] 。\n- 接下来的 4 轮,只有位置 0 的人在买票。\n位置 0 的人成功买到 5 张票,用掉 4 + 1 + 1 + 1 + 1 = 8 秒。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == tickets.length</code></li>\n\t<li><code>1 &lt;= n &lt;= 100</code></li>\n\t<li><code>1 &lt;= tickets[i] &lt;= 100</code></li>\n\t<li><code>0 &lt;= k &lt; n</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Easy",
"likes": 12,
"likes": 13,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -149,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"7.7K\", \"totalSubmission\": \"12.4K\", \"totalAcceptedRaw\": 7703, \"totalSubmissionRaw\": 12441, \"acRate\": \"61.9%\"}",
"stats": "{\"totalAccepted\": \"8.2K\", \"totalSubmission\": \"13.1K\", \"totalAcceptedRaw\": 8151, \"totalSubmissionRaw\": 13113, \"acRate\": \"62.2%\"}",
"hints": [
"Loop through the line of people and decrement the number of tickets for each to buy one at a time as if simulating the line moving forward. Keep track of how many tickets have been sold up until person k has no more tickets to buy.",
"Remember that those who have no more tickets to buy will leave the line."