Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Days to Make m Bouquets

med
30 min
Try to solve the Minimum Number of Days to Make m Bouquets problem.

Statement

You are given an integer array bloomDay, where bloomDay[i] is the day the ith flower blooms.

You want to make exactly m bouquets. Each bouquet must consist of exactly k flowers that are adjacent in the array, and each flower can be used in at most one bouquet.

Return the minimum day such that it is possible to make m bouquets by that day. If it is impossible to make m bouquets, return −1-1.

Note: A flower is considered available on day d if bloomDay[i] \leq d.

Constraints:

  • bloomDay.length == n

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq bloomDay[i] ≤109\leq 10^9

  • 1≤1 \leq m ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n

⋮
Tap here to switch tabs
Problem
Submissions

Problem: Minimum Number of Days to Make m Bouquets

med
30 min
Try to solve the Minimum Number of Days to Make m Bouquets problem.

Statement

You are given an integer array bloomDay, where bloomDay[i] is the day the ith flower blooms.

You want to make exactly m bouquets. Each bouquet must consist of exactly k flowers that are adjacent in the array, and each flower can be used in at most one bouquet.

Return the minimum day such that it is possible to make m bouquets by that day. If it is impossible to make m bouquets, return −1-1.

Note: A flower is considered available on day d if bloomDay[i] \leq d.

Constraints:

  • bloomDay.length == n

  • 1≤1 \leq n ≤105\leq 10^5

  • 1≤1 \leq bloomDay[i] ≤109\leq 10^9

  • 1≤1 \leq m ≤106\leq 10^6

  • 1≤1 \leq k ≤\leq n