1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-12-19 02:24:59 +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>给你一个由 <strong>不同</strong> 整数组成的整数数组 <code>arr</code> 和一个整数 <code>k</code> 。</p>\n\n<p>每回合游戏都在数组的前两个元素(即 <code>arr[0]</code> 和 <code>arr[1]</code> )之间进行。比较 <code>arr[0]</code> 与 <code>arr[1]</code> 的大小,较大的整数将会取得这一回合的胜利并保留在位置 <code>0</code> ,较小的整数移至数组的末尾。当一个整数赢得 <code>k</code> 个连续回合时,游戏结束,该整数就是比赛的 <strong>赢家</strong> 。</p>\n\n<p>返回赢得比赛的整数。</p>\n\n<p>题目数据 <strong>保证</strong> 游戏存在赢家。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<pre><strong>输入:</strong>arr = [2,1,3,5,4,6,7], k = 2\n<strong>输出:</strong>5\n<strong>解释:</strong>一起看一下本场游戏每回合的情况:\n<img alt=\"\" src=\"https://assets.leetcode-cn.com/aliyun-lc-upload/uploads/2020/07/30/q-example.png\" style=\"height: 90px; width: 400px;\">\n因此将进行 4 回合比赛,其中 5 是赢家,因为它连胜 2 回合。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre><strong>输入:</strong>arr = [3,2,1], k = 10\n<strong>输出:</strong>3\n<strong>解释:</strong>3 将会在前 10 个回合中连续获胜。\n</pre>\n\n<p><strong>示例 3</strong></p>\n\n<pre><strong>输入:</strong>arr = [1,9,8,2,3,7,6,4,5], k = 7\n<strong>输出:</strong>9\n</pre>\n\n<p><strong>示例 4</strong></p>\n\n<pre><strong>输入:</strong>arr = [1,11,22,33,44,55,66,77,88,99], k = 1000000000\n<strong>输出:</strong>99\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>2 &lt;= arr.length &lt;= 10^5</code></li>\n\t<li><code>1 &lt;= arr[i] &lt;= 10^6</code></li>\n\t<li><code>arr</code> 所含的整数 <strong>各不相同</strong> 。</li>\n\t<li><code>1 &lt;= k &lt;= 10^9</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 36,
"likes": 37,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -143,7 +143,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"14.2K\", \"totalSubmission\": \"31.1K\", \"totalAcceptedRaw\": 14241, \"totalSubmissionRaw\": 31148, \"acRate\": \"45.7%\"}",
"stats": "{\"totalAccepted\": \"14.4K\", \"totalSubmission\": \"31.6K\", \"totalAcceptedRaw\": 14436, \"totalSubmissionRaw\": 31565, \"acRate\": \"45.7%\"}",
"hints": [
"If k ≥ arr.length return the max element of the array.",
"If k < arr.length simulate the game until a number wins k consecutive games."