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)/用地毯覆盖后的最少白色砖块 [minimum-white-tiles-after-covering-with-carpets].html
2022-03-29 12:43:11 +08:00

45 lines
2.1 KiB
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>给你一个下标从<strong>&nbsp;0</strong>&nbsp;开始的 <strong>二进制</strong>&nbsp;字符串&nbsp;<code>floor</code>&nbsp;,它表示地板上砖块的颜色。</p>
<ul>
<li><code>floor[i] = '0'</code>&nbsp;表示地板上第&nbsp;<code>i</code>&nbsp;块砖块的颜色是 <strong>黑色</strong>&nbsp;</li>
<li><code>floor[i] = '1'</code>&nbsp;表示地板上第&nbsp;<code>i</code>&nbsp;块砖块的颜色是 <strong>白色</strong>&nbsp;</li>
</ul>
<p>同时给你&nbsp;<code>numCarpets</code>&nbsp;<code>carpetLen</code>&nbsp;。你有&nbsp;<code>numCarpets</code>&nbsp;&nbsp;<strong>黑色</strong>&nbsp;的地毯,每一条&nbsp;<strong>黑色</strong>&nbsp;的地毯长度都为&nbsp;<code>carpetLen</code>&nbsp;块砖块。请你使用这些地毯去覆盖砖块,使得未被覆盖的剩余 <strong>白色</strong>&nbsp;砖块的数目 <strong>最小</strong>&nbsp;。地毯相互之间可以覆盖。</p>
<p>请你返回没被覆盖的白色砖块的 <strong>最少</strong>&nbsp;数目。</p>
<p>&nbsp;</p>
<p><strong>示例 1</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2022/02/10/ex1-1.png" style="width: 400px; height: 73px;"></p>
<pre><b>输入:</b>floor = "10110101", numCarpets = 2, carpetLen = 2
<b>输出:</b>2
<b>解释:</b>
上图展示了剩余 2 块白色砖块的方案。
没有其他方案可以使未被覆盖的白色砖块少于 2 块。
</pre>
<p><strong>示例 2</strong></p>
<p><img alt="" src="https://assets.leetcode.com/uploads/2022/02/10/ex2.png" style="width: 353px; height: 123px;"></p>
<pre><b>输入:</b>floor = "11111", numCarpets = 2, carpetLen = 3
<b>输出:</b>0
<b>解释:</b>
上图展示了所有白色砖块都被覆盖的一种方案。
注意,地毯相互之间可以覆盖。
</pre>
<p>&nbsp;</p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 &lt;= carpetLen &lt;= floor.length &lt;= 1000</code></li>
<li><code>floor[i]</code> 要么是&nbsp;<code>'0'</code>&nbsp;,要么是&nbsp;<code>'1'</code>&nbsp;</li>
<li><code>1 &lt;= numCarpets &lt;= 1000</code></li>
</ul>