Minimum Number of Days to Make m Bouquets
You are given an integer array bloomDay where bloomDay[i] is the day the i-th flower blooms, plus integers m and k. To make one bouquet you need k adjacent flowers that have already bloomed. Return the minimum number of days you must wait to make m bouquets; if it is impossible to make that many, return -1.
Open official problem prompt ↗Find the earliest day on which enough adjacent flowers have bloomed to assemble m bouquets of k flowers each.
Watering a garden and waiting: each extra day opens more blossoms and never closes any, so you look for the first sunrise on which you can finally cut all the bouquets you need.
- Input
- bloomDay = [1,10,3,10,2], m = 3, k = 1
- Output
- 3
- Why
- Each bouquet needs only 1 flower. By day 3 the flowers with bloomDay 1, 3, and 2 have bloomed - three flowers, hence three single-flower bouquets; day 2 yields only two.
bloomDay.length == n1 <= n <= 10^51 <= bloomDay[i] <= 10^91 <= m <= 10^61 <= k <= n