flowerbed contains 0s (empty) and 1s (planted). Flowers cannot be planted in adjacent plots.
flowerbed
0
1
Return true if n new flowers can be planted without breaking that rule.
true
n
flowerbed = [1,0,0,0,1], n = 1
flowerbed = [1,0,0,0,1], n = 2
false
1 <= flowerbed.length <= 2 * 10^4 0 <= n <= flowerbed.length `flowerbed[i]` is `0` or `1`.
Topics
Implement canPlaceFlowers in the editor and return the answer — printing it is never graded.
canPlaceFlowers
Problem 66 of 1146 in the arena