Practice/Amazon/Leetcode 1482. Minimum Number of Days to Make m Bouquets
CodingMust
You have a garden with flowers arranged in a straight line. Each flower will bloom on a specific day, given in the array bloomDay, where bloomDay[i] represents the day when the flower at position i will bloom.
You need to create m bouquets, and each bouquet must contain exactly k adjacent flowers that have already bloomed. Your task is to find the minimum number of days you need to wait before you can make all m bouquets.
If it's impossible to make m bouquets (for example, if you don't have enough flowers in total), return -1.
m bouquets can be formedk adjacent flowers (consecutive positions in the garden)m bouquets is impossible, return -1Example 1:
Input: bloomDay = [1, 10, 3, 10, 2], m = 3, k = 1 Output: 3 Explanation: On day 3, flowers at positions 0 (bloomed day 1), 2 (bloomed day 3), and 4 (bloomed day 2) have all bloomed. Since k=1, each single flower can form a bouquet, so we can make 3 bouquets.
Example 2:
` Input: bloomDay = [1, 10, 3, 10, 2], m = 2, k = 2 Output: 10 Explanation: We need 2 bouquets with 2 adjacent flowers each (4 flowers total).
Example 3:
Input: bloomDay = [7, 7, 7, 7], m = 2, k = 3 Output: -1 Explanation: We need 2 * 3 = 6 flowers but only have 4 flowers total.