1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-07 08:21:41 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2023-12-09 19:57:46 +08:00
parent 9bc4722a45
commit 3770b44d1e
4792 changed files with 10889 additions and 10886 deletions

View File

@@ -12,7 +12,7 @@
"translatedContent": "<p>给你一个下标从 <strong>0 </strong>开始的整数数组 <code>coins</code>,表示可用的硬币的面值,以及一个整数 <code>target</code> 。</p>\n\n<p>如果存在某个 <code>coins</code> 的子序列总和为 <code>x</code>,那么整数 <code>x</code> 就是一个 <strong>可取得的金额 </strong>。</p>\n\n<p>返回需要添加到数组中的<strong> 任意面值 </strong>硬币的 <strong>最小数量 </strong>,使范围 <code>[1, target]</code> 内的每个整数都属于 <strong>可取得的金额</strong> 。</p>\n\n<p>数组的 <strong>子序列</strong> 是通过删除原始数组的一些(<strong>可能不删除</strong>)元素而形成的新的 <strong>非空</strong> 数组,删除过程不会改变剩余元素的相对位置。</p>\n\n<p>&nbsp;</p>\n\n<p><strong class=\"example\">示例 1</strong></p>\n\n<pre>\n<strong>输入:</strong>coins = [1,4,10], target = 19\n<strong>输出:</strong>2\n<strong>解释:</strong>需要添加面值为 2 和 8 的硬币各一枚,得到硬币数组 [1,2,4,8,10] 。\n可以证明从 1 到 19 的所有整数都可由数组中的硬币组合得到,且需要添加到数组中的硬币数目最小为 2 。\n</pre>\n\n<p><strong class=\"example\">示例 2</strong></p>\n\n<pre>\n<strong>输入:</strong>coins = [1,4,10,5,7,19], target = 19\n<strong>输出:</strong>1\n<strong>解释:</strong>只需要添加一枚面值为 2 的硬币,得到硬币数组 [1,2,4,5,7,10,19] 。\n可以证明从 1 到 19 的所有整数都可由数组中的硬币组合得到,且需要添加到数组中的硬币数目最小为 1 。</pre>\n\n<p><strong class=\"example\">示例 3</strong></p>\n\n<pre>\n<strong>输入:</strong>coins = [1,1,1], target = 20\n<strong>输出:</strong>3\n<strong>解释:</strong>\n需要添加面值为 4 、8 和 16 的硬币各一枚,得到硬币数组 [1,1,1,4,8,16] 。 \n可以证明从 1 到 20 的所有整数都可由数组中的硬币组合得到,且需要添加到数组中的硬币数目最小为 3 。</pre>\n\n<p>&nbsp;</p>\n\n<p><strong>提示:</strong></p>\n\n<ul>\n\t<li><code>1 &lt;= target &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= coins.length &lt;= 10<sup>5</sup></code></li>\n\t<li><code>1 &lt;= coins[i] &lt;= target</code></li>\n</ul>\n",
"isPaidOnly": false,
"difficulty": "Medium",
"likes": 24,
"likes": 26,
"dislikes": 0,
"isLiked": null,
"similarQuestions": "[]",
@@ -155,7 +155,7 @@
"__typename": "CodeSnippetNode"
}
],
"stats": "{\"totalAccepted\": \"3.5K\", \"totalSubmission\": \"7.2K\", \"totalAcceptedRaw\": 3520, \"totalSubmissionRaw\": 7242, \"acRate\": \"48.6%\"}",
"stats": "{\"totalAccepted\": \"3.6K\", \"totalSubmission\": \"7.3K\", \"totalAcceptedRaw\": 3552, \"totalSubmissionRaw\": 7292, \"acRate\": \"48.7%\"}",
"hints": [
"Sort the coins array and maintain the smallest sum that is unobtainable by induction.",
"If we dont use any coins, the smallest integer that we cannot obtain by sum is <code>1</code>. Suppose currently, for a fixed set of the first several coins the smallest integer that we cannot obtain is <code>x + 1</code>, namely we can form all integers in the range <code>[1, x]</code> but not <code>x + 1</code>.",