1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-08 08:51:42 +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,18 +12,30 @@
"translatedContent": "<p>一张桌子上总共有 <code>n</code>&nbsp;个硬币 <b>栈</b>&nbsp;。每个栈有 <strong>正整数</strong>&nbsp;个带面值的硬币。</p>\n\n<p>每一次操作中,你可以从任意一个栈的 <strong>顶部</strong>&nbsp;取出 1 个硬币,从栈中移除它,并放入你的钱包里。</p>\n\n<p>给你一个列表&nbsp;<code>piles</code>&nbsp;,其中&nbsp;<code>piles[i]</code>&nbsp;是一个整数数组,分别表示第 <code>i</code>&nbsp;个栈里 <strong>从顶到底</strong>&nbsp;的硬币面值。同时给你一个正整数&nbsp;<code>k</code>&nbsp;,请你返回在&nbsp;<strong>恰好</strong>&nbsp;进行&nbsp;<code>k</code>&nbsp;次操作的前提下,你钱包里硬币面值之和&nbsp;<strong>最大为多少</strong>&nbsp;。</p>\n\n<p>&nbsp;</p>\n\n<p><strong>示例 1</strong></p>\n\n<p><img alt=\"\" src=\"https://assets.leetcode.com/uploads/2019/11/09/e1.png\" style=\"width: 600px; height: 243px;\" /></p>\n\n<pre>\n<b>输入:</b>piles = [[1,100,3],[7,8,9]], k = 2\n<b>输出:</b>101\n<strong>解释:</strong>\n上图展示了几种选择 k 个硬币的不同方法。\n我们可以得到的最大面值为 101 。\n</pre>\n\n<p><strong>示例 2</strong></p>\n\n<pre>\n<b>输入:</b>piles = [[100],[100],[100],[100],[100],[100],[1,1,1,1,1,1,700]], k = 7\n<b>输出:</b>706\n<strong>解释:\n</strong>如果我们所有硬币都从最后一个栈中取,可以得到最大面值和。\n</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>n == piles.length</code></li>\n\t<li><code>1 &lt;= n &lt;= 1000</code></li>\n\t<li><code>1 &lt;= piles[i][j] &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= k &lt;= sum(piles[i].length) &lt;= 2000</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Hard",
"likes": 27,
"likes": 35,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
"contributors": [],
"langToValidPlayground": "{\"cpp\": false, \"java\": true, \"python\": true, \"python3\": false, \"mysql\": false, \"mssql\": false, \"oraclesql\": false, \"c\": false, \"csharp\": false, \"javascript\": false, \"ruby\": false, \"bash\": false, \"swift\": false, \"golang\": false, \"scala\": false, \"html\": false, \"pythonml\": false, \"kotlin\": false, \"rust\": false, \"php\": false, \"typescript\": false, \"racket\": false, \"erlang\": false, \"elixir\": false}",
"topicTags": [
{
"name": "Array",
"slug": "array",
"translatedName": "数组",
"__typename": "TopicTagNode"
},
{
"name": "Dynamic Programming",
"slug": "dynamic-programming",
"translatedName": "动态规划",
"__typename": "TopicTagNode"
},
{
"name": "Prefix Sum",
"slug": "prefix-sum",
"translatedName": "前缀和",
"__typename": "TopicTagNode"
}
],
"companyTagStats": null,
@@ -137,7 +149,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"3.4K\", \"totalSubmission\": \"6.8K\", \"totalAcceptedRaw\": 3414, \"totalSubmissionRaw\": 6776, \"acRate\": \"50.4%\"}",
"stats": "{\"totalAccepted\": \"4.4K\", \"totalSubmission\": \"8.4K\", \"totalAcceptedRaw\": 4438, \"totalSubmissionRaw\": 8399, \"acRate\": \"52.8%\"}",
"hints": [
"For each pile i, what will be the total value of coins we can collect if we choose the first j coins?",
"How can we use dynamic programming to combine the results from different piles to find the most optimal answer?"