Skip to content

Practice Minimum Number of Days to Make m Bouquets

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#1482
LeetCode Problem

Minimum Number of Days to Make m Bouquets

Problem Statement

You are given an integer array bloomDay, an integer m and an integer k. You want to make m bouquets. To make a bouquet, you need to use k adjacent flowers from the garden. The garden consists of n flowers, the ith flower will bloom in the bloomDay[i] and then can be used in exactly one bouquet. Return the minimum number of days you need to wait to be able to make m bouquets from the garden. If it is impossible to make m bouquets return -1.

Source: Minimum Number of Days to Make m Bouquets on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
bloomDay = [1,10,3,10,2], m = 3, k = 1
Output
3

# Example 2

Input
bloomDay = [1,10,3,10,2], m = 3, k = 2
Output
-1

# Example 3

Input
bloomDay = [7,7,7,7,12,7,7], m = 2, k = 3
Output
12

Constraints

bloomDay.length == n
1 <= n <= 10^5
1 <= bloomDay[i] <= 10^9
1 <= m <= 10^6
1 <= k <= n

Related LeetCode Problems

Practice more problems similar to Minimum Number of Days to Make m Bouquets.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.