1
0
mirror of https://gitee.com/coder-xiaomo/leetcode-problemset synced 2025-09-02 14:12:17 +08:00
Code Issues Projects Releases Wiki Activity GitHub Gitee
This commit is contained in:
2022-03-29 12:43:11 +08:00
parent 58bbdfd57c
commit 2b0511d272
10721 changed files with 8123 additions and 8119 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>