low
to the minimum bloom day and high
to the maximum bloom day.low
is less than or equal to high
, do the following:
a. Calculate mid
as the average of low
and high
.
b. Check if it's possible to make m
bouquets by day mid
.
c. If it is possible, update high
to mid - 1
(we will look for a smaller number of days).
d. If it is not possible, update low
to mid + 1
(we need more days).m
bouquets can be made, return that day. Otherwise, return -1
if no such day exists.