Loading...
Given a flowerbed (array of 0s and 1s) and n new flowers, return True if n new flowers can be planted without violating the no-adjacent rule.
1,0,0,0,1 1
True
[1,0,0,0,1], where 0 indicates an empty plot and 1 indicates a plot with a flower.1 new flower, so we look for a plot where we can plant it without violating the no-adjacent rule.[1,0,0,1,1] or at other positions, but since we only need to plant 1 flower, we can choose any of these valid positions.True because we can plant the new flower without violating the rule.