Find the minimum day when it becomes possible to make exactly or at least bouquets, each requiring adjacent bloomed flowers.
You are given an array bloomDay, where bloomDay[i] is the day the flower at index i blooms.
A bouquet can be made only from adjacent flowers that have all bloomed by the same day.
Your task is to determine the minimum day on which it is possible to make bouquets. If it is impossible to make that many bouquets, return -1.
A flower can be used in at most one bouquet.
For a fixed day, you can check whether enough bouquets can be formed from consecutive bloomed flowers. The key is that this feasibility test is monotonic with respect to the day, which makes the problem a good fit for binary search on the answer.
bloomDaym and k-1 if making m bouquets is impossiblek adjacent flowersm * k > bloomDay.length, the answer is -1d such that at least m bouquets can be formed using flowers with bloom day <= dExample 1
Input
bloomDay = [1,10,3,10,2], m = 3, k = 1
Output
3
Explanation
By day 3, flowers at indices 0, 2, and 4 have bloomed, so 3 bouquets of size 1 can be made.
Example 2
Input
bloomDay = [1,10,3,10,2], m = 3, k = 2
Output
-1
Explanation
There are only 5 flowers total, but 3 bouquets of 2 flowers each require 6 flowers.
Example 3
Input
bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3
Output
12
Explanation
By day 7, only one bouquet of 3 adjacent bloomed flowers can be formed. By day 12, all flowers are bloomed, allowing two bouquets.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.