https://leetcode.com/problems/can-place-flowers/description/?envType=study-plan-v2&envId=leetcode-75

# 첫번째 풀이
class Solution:
def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:
cnt = 0
if len(flowerbed) <3:
if 1 in flowerbed:
cnt = 0
else:
cnt = 1
else:
for i in range(len(flowerbed)):
if i == 0 and flowerbed[i] == 0 and flowerbed[i+1] == 0:
flowerbed[i] = 1
cnt += 1
elif i == len(flowerbed) -1 and flowerbed[i] == 0 and flowerbed[i-1] == 0:
flowerbed[i] = 1
cnt += 1
elif 0 < i < len(flowerbed) - 1 and flowerbed[i] == 0 and flowerbed[i-1] == 0 and flowerbed[i+1] == 0:
flowerbed[i] = 1
cnt += 1
return True if cnt >= n else False
# 최종 풀이
class Solution:
def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:
cnt = 0
for i in range(len(flowerbed)):
if flowerbed[i] == 0 and flowerbed[max(0, i-1)] == 0 and flowerbed[min(len(flowerbed)-1, i+1)] == 0:
flowerbed[i] = 1
cnt += 1
return True if cnt >= n else False