class Solution:
def minDays(self, bloomDay: List[int], m: int, k: int) -> int:
x = [0, max(bloomDay), -1]
while x[1] - x[0] - 1:
mid, bouquets, stacked = (x[0] + x[1]) >> 1, 0, 0
for flower in bloomDay:
stacked = stacked + 1 if flower <= mid else 0
if stacked == k:
bouquets, stacked = bouquets + 1, 0
x[bouquets >= m] = mid
return x[1 - 2*(m * k > len(bloomDay))]
별로 어려운 문제가 아닐 것이라고 생각했고, 이분탐색 당첨
줄 수를 줄이려고 좀 거지 같이 짠 부분은 이해 바랍니다.
댓글 0