Baseline Binary Search · In Search Space O(n log D), where D is the latest bloom day · O(1)
A factory installs stations along one row, each coming online on a known day. An assembly cell needs k neighbouring stations active, and production requires m such cells. Find the first day on which the floor can field m cells, or admit that the row is too short to ever do it.
Input: An array bloomDay of n integers (the day each station comes online), an integer m (cells required) and an integer k (adjacent stations per cell).
Output: The minimum day on which m bouquets of k adjacent bloomed stations can be formed, or -1 when fewer than m * k stations exist.
1 <= bloomDay.length <= 10^51 <= bloomDay[i] <= 10^91 <= m <= 10^61 <= k <= nInput: {"bloomDay":[1,10,3,10,2],"m":3,"k":1}
Output: 3
By day 3 the stations at positions 1, 3 and 5 have come online, giving three single-station cells.
Input: {"bloomDay":[7,7,7,7,12,7,7],"m":2,"k":3}
Output: 12
Day 7 offers only one run of four adjacent stations; waiting for day 12 lights the whole row, enough for two cells.