Leetcode 605 Solution
This article provides solution to leetcode question 605 (can-place-flowers)
Access this page by simply typing in "lcs 605" in your browser address bar if you have bunnylol configured.
Leetcode Question Link
class Solution: def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool: last = -2 for i, v in enumerate(flowerbed): if v == 1: last = i continue if i - last > 1 and (i == len(flowerbed) - 1 or flowerbed[i + 1] == 0): n -= 1 last = i return n <= 0