Skip to content

1482. Minimum Number of Days to Make m Bouquets #277

Answered by mah-shamim
mah-shamim asked this question in Q&A
Discussion options

You must be logged in to vote

The problem requires finding the minimum number of days to wait to make exactly m bouquets, each containing k adjacent flowers, using the array bloomDay. If it is not possible, return -1. The task is efficiently solved using a binary search approach on the number of days.

Key Points

  1. Binary Search Feasibility: The problem can be optimized using binary search because if it is possible to make m bouquets in x days, it will also be possible for all days greater than x.
  2. Adjacent Constraint: Each bouquet requires k adjacent flowers. This introduces the need for sequential checks.
  3. Edge Case: If m * k > n, it is impossible to make the bouquets, and the function should immediately return -1.

App…

Replies: 1 comment 2 replies

Comment options

You must be logged in to vote
2 replies
@basharul-siddike
Comment options

@mah-shamim
Comment options

mah-shamim Jan 21, 2025
Maintainer Author

Answer selected by basharul-siddike
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
question Further information is requested medium Difficulty
2 participants