Earliest Day for m Disjoint Adjacent-Flower Bouquets
Quick Overview
Earliest Day for m Disjoint Adjacent-Flower Bouquets. Flower i becomes available on bloomDay[i]. Each bouquet requires k adjacent garden positions,all bloomed by the chosen day,and each flower may be used in at most one bouquet.
Earliest Day for m Disjoint Adjacent-Flower Bouquets
Company: Flipkart
Role: Software Engineer
Category: Coding & Algorithms
Difficulty: medium
Interview Round: Other
### Problem
Flower i becomes available on bloomDay[i]. Each bouquet requires k adjacent garden positions,all bloomed by the chosen day,and each flower may be used in at most one bouquet. Return the earliest day when m bouquets can be formed,or -1 if impossible.
```cpp
class Solution {
public:
int minDays(vector<int>& bloomDay, int m, int k);
};
```
### Examples
**Example 1:**
```text
Input: bloomDay = [2,5,2,5], m = 2, k = 2
Output: 5
Explanation: Before day5,the two bloomed flowers are isolated. On day5,all four bloom and form two disjoint adjacent pairs.
```
**Example 2:**
```text
Input: bloomDay = [1,2,3], m = 2, k = 2
Output: -1
Explanation: Two bouquets require four distinct flowers,but only three exist.
```
### Constraints
- n equals bloomDay.length,with `1 <= n <= 100000`.
- `1 <= bloomDay[i] <= 1000000000`.
- `1 <= m <= 1000000` and `1 <= k <= n`.
### Contract considerations
Flowers not selected for a bouquet may remain unused.
```hint Read the boundary condition
Adjacency follows the original garden order, and no flower may serve two bouquets. Account for impossible requests and flowers blooming on the chosen day.
```
### Boundary reminders
Flowers not selected for a bouquet may remain unused.
Overview: Earliest Day for m Disjoint Adjacent-Flower Bouquets. Flower i becomes available on bloomDay[i]. Each bouquet requires k adjacent garden positions,all bloomed by the chosen day,and each flower may be used in at most one bouquet.
Earliest Day for m Disjoint Adjacent-Flower Bouquets
Flipkart
Source window: 0–3 months · as of Oct 21, 2026
mediumSoftware EngineerOtherCoding & Algorithms
0
0
Problem
Flower i becomes available on bloomDay[i]. Each bouquet requires k adjacent garden positions,all bloomed by the chosen day,and each flower may be used in at most one bouquet. Return the earliest day when m bouquets can be formed,or -1 if impossible.
class Solution {
public:
int minDays(vector<int>& bloomDay, int m, int k);
};
Examples
Example 1:
Input: bloomDay = [2,5,2,5], m = 2, k = 2
Output: 5
Explanation: Before day5,the two bloomed flowers are isolated. On day5,all four bloom and form two disjoint adjacent pairs.
Example 2:
Input: bloomDay = [1,2,3], m = 2, k = 2
Output: -1
Explanation: Two bouquets require four distinct flowers,but only three exist.
Constraints
n equals bloomDay.length,with
1 <= n <= 100000
.
1 <= bloomDay[i] <= 1000000000
.
1 <= m <= 1000000
and
1 <= k <= n
.
Contract considerations
Flowers not selected for a bouquet may remain unused.
Boundary reminders
Flowers not selected for a bouquet may remain unused.