The problem. A garden has n flowers in a row; flower i blooms on day bloomDay[i]. A bouquet needs k adjacent bloomed flowers, and each flower can be in only one bouquet. Return the minimum number of days to wait before you can make m bouquets, or -1 if it's impossible.
bloomDay = [1, 10, 3, 10, 2], m = 3, k = 1 -> 3
bloomDay = [1, 10, 3, 10, 2], m = 3, k = 2 -> -1 (needs 6 flowers, there are 5)
bloomDay = [7, 7, 7, 7, 12, 7, 7], m = 2, k = 3 -> 12Members only · free account
The rest of this lesson, with 6 more sections, 1 drawing, a dry-run simulator and code in JavaScript, Python, Java and C++, opens with a free account.
Not ready yet? The Arrays course is free to read, no account needed.
In the rest of this lesson