We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent 557cf9a commit 3c322daCopy full SHA for 3c322da
solution/0605.Can Place Flowers/Solution.py
@@ -0,0 +1,17 @@
1
+class Solution:
2
+ def canPlaceFlowers(self, flowerBed, n):
3
+ """
4
+ type flowerBed : List[int], n : int
5
+ rtype : bool
6
7
+
8
+ for i in range(len(flowerBed)):
9
+ if i == 0 and flowerBed[0] == 0: # for 1st Element
10
+ if len(flowerBed) == 1 or (len(flowerBed) > 1 and flowerBed[1] == 0):
11
+ n -= 1
12
+ elif i == len(flowerBed)-1 and flowerBed[i] == 0 and flowerBed[i-1] == 0: # for last element
13
14
+ elif flowerBed[i] == 0 and flowerBed[i-1] == 0 and flowerBed[i+1] == 0:
15
16
17
+ return n==0
0 commit comments