24. Minimum Days to Make M Bouquets
β GFG solution to the Minimum Days to Make M Bouquets problem: find minimum days required to create m bouquets using binary search optimization technique. π
π§© Problem Description
π Examples
Example 1
Input: m = 3, k = 2, arr[] = [3, 4, 2, 7, 13, 8, 5]
Output: 8
Explanation: We need 3 bouquets and each bouquet should have 2 flowers.
After day 8: [x, x, x, x, _, x, x], we can make first bouquet from the first 2 flowers,
second bouquet from the next 2 flowers and the third bouquet from the last 2 flowers.Example 2
Input: m = 2, k = 3, arr[] = [5, 5, 5, 5, 10, 5, 5]
Output: 10
Explanation: We need 2 bouquets and each bouquet should have 3 flowers,
After day 5: [x, x, x, x, _, x, x], we can make one bouquet of the first three flowers
that bloomed, but cannot make another bouquet. After day 10: [x, x, x, x, x, x, x],
Now we can make two bouquets, taking 3 adjacent flowers in one bouquet.Example 3
π Constraints
β
My Approach
Binary Search + Greedy Validation
π Time and Auxiliary Space Complexity
π§βπ» Code (C++)
β Code (Java)
π Code (Python)
π§ Contribution and Support
πVisitor Count
Last updated