Skip to content

Commit 15b456e

Browse files
committed
Time: 130 ms (64.56%) | Memory: 17 MB (21.94%) - LeetSync
1 parent ce9f2fb commit 15b456e

File tree

1 file changed

+7
-6
lines changed

1 file changed

+7
-6
lines changed
Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,13 @@
11
class Solution:
22
def canPlaceFlowers(self, flowerbed: List[int], n: int) -> bool:
3-
f = [0] + flowerbed + [0]
43

5-
for i in range(1, len(f)-1):
6-
if not f[i-1] and not f[i] and not f[i+1] and n:
7-
f[i] = 1
4+
flower = [0] + flowerbed + [0]
5+
6+
for i in range(1, len(flower)-1):
7+
if not flower[i-1] and not flower[i] and not flower[i+1] and n > 0:
8+
flower[i] = 1
89
n -=1
9-
if n == 0:
10-
break
10+
print(flower)
11+
print(n)
1112
return n == 0
1213

0 commit comments

Comments
 (0)