Skip to content

visual walkthrough

Minimum Number of Days to Make m Bouquets

MediumBinary Search on AnswerReported at: Google

Search on days, checking contiguous groups.

Solve on LeetCode

The idea

Flowers stay open once they bloom, so the number of bouquets you can make never goes down as days pass.

That makes "enough bouquets by day d?" a yes/no that flips once: binary search the day.

Complexity

approachtimespace
Try every bloom dayO(n · d)O(1)
Binary search on the dayO(n log max)O(1)

More walkthroughs