1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-13 19:31:42 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee

add leetcode problem-cn part3

This commit is contained in:
2022-03-27 20:46:41 +08:00
parent 6dafca13c5
commit dfacb20d31
1385 changed files with 115239 additions and 3 deletions

View File

@@ -0,0 +1,30 @@
<p>假设有一个很长的花坛,一部分地块种植了花,另一部分却没有。可是,花不能种植在相邻的地块上,它们会争夺水源,两者都会死去。</p>
<p>给你一个整数数组  <code>flowerbed</code> 表示花坛,由若干 <code>0</code><code>1</code> 组成,其中 <code>0</code> 表示没种植花,<code>1</code> 表示种植了花。另有一个数 <code>n</code><strong> </strong>,能否在不打破种植规则的情况下种入 <code>n</code><strong> </strong>朵花?能则返回 <code>true</code> ,不能则返回 <code>false</code></p>
<p> </p>
<p><strong>示例 1</strong></p>
<pre>
<strong>输入:</strong>flowerbed = [1,0,0,0,1], n = 1
<strong>输出:</strong>true
</pre>
<p><strong>示例 2</strong></p>
<pre>
<strong>输入:</strong>flowerbed = [1,0,0,0,1], n = 2
<strong>输出:</strong>false
</pre>
<p> </p>
<p><strong>提示:</strong></p>
<ul>
<li><code>1 <= flowerbed.length <= 2 * 10<sup>4</sup></code></li>
<li><code>flowerbed[i]</code><code>0</code><code>1</code></li>
<li><code>flowerbed</code> 中不存在相邻的两朵花</li>
<li><code>0 <= n <= flowerbed.length</code></li>
</ul>