Minimum Number of Days to Make m Bouquets
Solve this the way you would in the interview: out loud, on a timer, with an AI interviewer asking follow-ups while you code. You get a scored report at the end.
Practice this as a mock interviewFree to start, no account neededProblem
A garden has n flowers in a row. Flower i blooms on day bloomDay[i] and stays bloomed forever after. You want to make m bouquets, and each bouquet needs exactly k **adjacent** bloomed flowers. A flower can belong to at most one bouquet.
Return the minimum day number on which it is possible to make all m bouquets. If it can never be done (there are fewer than m * k flowers in total), return -1.
Note that m * k can exceed the 32-bit range. Aim for O(n log(max bloomDay)) time.
Examples
Constraints
- 1 <= bloomDay.length <= 10^5
- 1 <= bloomDay[i] <= 10^9
- 1 <= m <= 10^6
- 1 <= k <= n
What the interviewer grades
A correct solution is one of five scores. The report also grades problem understanding (did you clarify inputs and edge cases before coding), problem solving, communication while you work, code quality, and testing. See a sample report, or read up on the pattern in the lessons.