Skip to content

Commit 851bd72

Browse files
authored
Update Solution.py
1 parent 3c322da commit 851bd72

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

solution/0605.Can Place Flowers/Solution.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,12 @@ def canPlaceFlowers(self, flowerBed, n):
99
if i == 0 and flowerBed[0] == 0: # for 1st Element
1010
if len(flowerBed) == 1 or (len(flowerBed) > 1 and flowerBed[1] == 0):
1111
n -= 1
12+
flowerBed[0] = 1
1213
elif i == len(flowerBed)-1 and flowerBed[i] == 0 and flowerBed[i-1] == 0: # for last element
1314
n -= 1
15+
flowerBed[i] = 1
1416
elif flowerBed[i] == 0 and flowerBed[i-1] == 0 and flowerBed[i+1] == 0:
1517
n -= 1
18+
flowerBed[i] = 1
1619

17-
return n==0
20+
return n==0

0 commit comments

Comments
 (0)