i opens on day bloom[i] and stays open after that.
You need bouquets bouquets, each made of exactly size flowers that stand next to each other. A flower can go into only one bouquet.
Return the earliest day by which all the bouquets can be made, or -1 if that never happens.bloom=[5, 2, 2, 8, 3, 3], bouquets=2, size=2 → 3
By day 3 flowers 2, 3, 5 and 6 (counting from one) are open: pairs 2–3 and 5–6 make two bouquets.
bloom=[4, 4, 4], bouquets=2, size=2 → -1
Two bouquets of two need four flowers, but only three grow.
bloom=[1, 9, 1, 1], bouquets=1, size=3 → 9
Three neighbouring open flowers exist only from day 9: flowers 2–4.
bloom=[5, 2, 2, 8, 3, 3], bouquets=2, size=2
3
Run checks the first 3 tests in your browser. Submit checks all 96 tests on the server, hidden ones included.