Skip to content

Commit 319f67a

Browse files
committed
1482
1 parent 9c430d0 commit 319f67a

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

Jun-19-24.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
class Solution:
2+
def minDays(self, bloomDay: List[int], m: int, k: int) -> int:
3+
if len(bloomDay)//k < m:
4+
return -1
5+
def isPossible(bloomDay,m,k,n):
6+
flowers = 0
7+
for b in bloomDay:
8+
if b<=n:
9+
flowers += 1
10+
if flowers==k:
11+
flowers = 0
12+
m -= 1
13+
else:
14+
flowers = 0
15+
if m==0:
16+
return True
17+
return m==0
18+
19+
low,high = 0,max(bloomDay)
20+
while low<high:
21+
mid = (low+high)//2
22+
if isPossible(bloomDay,m,k,mid):
23+
high = mid
24+
else:
25+
low = mid + 1
26+
return low
27+
28+
29+

0 commit comments

Comments
 (0)