You are given an integer array bloomDay and two integers m and k. Flower i blooms on day bloomDay[i] and stays open afterwards. A bouquet needs k adjacent flowers from the garden, and each flower can go into at most one bouquet. Return the minimum number of days you need to wait to make m bouquets, or -1 if it is impossible.
You are given an integer array bloomDay and two integers m and k. Flower i blooms on day bloomDay[i] and stays open afterwards. A bouquet needs k adjacent flowers from the garden, and each flower can go into at most one bouquet. Return the minimum number of days you need to wait to make m bouquets, or -1 if it is impossible.
Example 1:
Input: {"bloomDay":[1,10,3,10,2],"m":3,"k":1}
Output: 3
Constraints:
bloomDay.length==n
1≤n≤105
1≤bloomDay[i]≤109
1≤m≤106
1≤k≤n
Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result
Run code to see results.
Input
arr ={"bloomDay":[1,10,3,10,2],"m":3,"k":1}
The garden has 5 flowers; each label is the day that flower opens. We need 3 bouquets of 1 adjacent open flower.