mirror of
https://gitee.com/coder-xiaomo/leetcode-problemset
synced 2025-09-09 01:11:42 +08:00
update
This commit is contained in:
@@ -12,7 +12,7 @@
|
||||
"translatedContent": "<p>给你一个下标从 <strong>0</strong> 开始的整数数组 <code>nums</code> ,它表示一个 <strong>栈</strong> ,其中 <code>nums[0]</code> 是栈顶的元素。</p>\n\n<p>每一次操作中,你可以执行以下操作 <strong>之一</strong> :</p>\n\n<ul>\n\t<li>如果栈非空,那么 <strong>删除</strong> 栈顶端的元素。</li>\n\t<li>如果存在 1 个或者多个被删除的元素,你可以从它们中选择任何一个,<b>添加</b> 回栈顶,这个元素成为新的栈顶元素。</li>\n</ul>\n\n<p>同时给你一个整数 <code>k</code> ,它表示你总共需要执行操作的次数。</p>\n\n<p>请你返回 <strong>恰好</strong> 执行 <code>k</code> 次操作以后,栈顶元素的 <strong>最大值</strong> 。如果执行完 <code>k</code> 次操作以后,栈一定为空,请你返回 <code>-1</code> 。</p>\n\n<p> </p>\n\n<p><strong>示例 1:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [5,2,2,4,0,6], k = 4\n<b>输出:</b>5\n<strong>解释:</strong>\n4 次操作后,栈顶元素为 5 的方法之一为:\n- 第 1 次操作:删除栈顶元素 5 ,栈变为 [2,2,4,0,6] 。\n- 第 2 次操作:删除栈顶元素 2 ,栈变为 [2,4,0,6] 。\n- 第 3 次操作:删除栈顶元素 2 ,栈变为 [4,0,6] 。\n- 第 4 次操作:将 5 添加回栈顶,栈变为 [5,4,0,6] 。\n注意,这不是最后栈顶元素为 5 的唯一方式。但可以证明,4 次操作以后 5 是能得到的最大栈顶元素。\n</pre>\n\n<p><strong>示例 2:</strong></p>\n\n<pre>\n<b>输入:</b>nums = [2], k = 1\n<b>输出:</b>-1\n<b>解释:</b>\n第 1 次操作中,我们唯一的选择是将栈顶元素弹出栈。\n由于 1 次操作后无法得到一个非空的栈,所以我们返回 -1 。\n</pre>\n\n<p> </p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 <= nums.length <= 10<sup>5</sup></code></li>\n\t<li><code>0 <= nums[i], k <= 10<sup>9</sup></code></li>\n</ul>\n",
|
||||
"isPaidOnly": false,
|
||||
"difficulty": "Medium",
|
||||
"likes": 14,
|
||||
"likes": 15,
|
||||
"dislikes": 0,
|
||||
"isLiked": null,
|
||||
"similarQuestions": "[]",
|
||||
@@ -143,7 +143,7 @@
|
||||
"__typename": "CodeSnippetNode"
|
||||
}
|
||||
],
|
||||
"stats": "{\"totalAccepted\": \"6.9K\", \"totalSubmission\": \"34.9K\", \"totalAcceptedRaw\": 6922, \"totalSubmissionRaw\": 34882, \"acRate\": \"19.8%\"}",
|
||||
"stats": "{\"totalAccepted\": \"7.3K\", \"totalSubmission\": \"36.1K\", \"totalAcceptedRaw\": 7338, \"totalSubmissionRaw\": 36079, \"acRate\": \"20.3%\"}",
|
||||
"hints": [
|
||||
"For each index i, how can we check if nums[i] can be present at the top of the pile or not after k moves?",
|
||||
"For which conditions will we end up with an empty pile?"
|
||||
|
Reference in New Issue
Block a user