count
to 0
to keep track of the number of flowers that can be planted.flowerbed
array.flowerbed[i] == 0
).count
and mark the current plot as planted by setting flowerbed[i] = 1
.count
becomes equal to or greater than n
, return true
.count
is less than n
, return false
.