traverse the flowerbed. if a proper slot is found, r++. if the non-adjacent rule is violated, r--. finally, compare n with r.

```
r = 0
c = 1
for f in flowerbed:
if f==1:
if c==2:
r-=1
else:
c = 0
else:
if c==2:
c=0
c+=1
if c==2:
r += 1
return n<=r
```