1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-01-10 18:48:13 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
leetcode-problemset/leetcode-cn/problem (Chinese)/拿硬币 [na-ying-bi].html
2022-03-29 12:43:11 +08:00

27 lines
780 B
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<p>桌上有 <code>n</code> 堆力扣币,每堆的数量保存在数组 <code>coins</code> 中。我们每次可以选择任意一堆,拿走其中的一枚或者两枚,求拿完所有力扣币的最少次数。</p>
<p><strong>示例 1</strong></p>
<blockquote>
<p>输入:<code>[4,2,1]</code></p>
<p>输出:<code>4</code></p>
<p>解释:第一堆力扣币最少需要拿 2 次,第二堆最少需要拿 1 次,第三堆最少需要拿 1 次,总共 4 次即可拿完。</p>
</blockquote>
<p><strong>示例 2</strong></p>
<blockquote>
<p>输入:<code>[2,3,10]</code></p>
<p>输出:<code>8</code></p>
</blockquote>
<p><strong>限制:</strong></p>
<ul>
<li><code>1 &lt;= n &lt;= 4</code></li>
<li><code>1 &lt;= coins[i] &lt;= 10</code></li>
</ul>