LC 0605 [E] Can Place Flowers - ALawliet/algorithms GitHub Wiki
class Solution:
def canPlaceFlowers(self, A, N):
for i in range(len(A)):
# is 0 and left is clear and right is clear
if (A[i] == 0 and (i == 0 or A[i-1] == 0) and (i == len(A)-1 or A[i+1] == 0)):
N -= 1
A[i] = 1
return N <= 0