2136. Earliest Possible Day of Full Bloom Hard
1/**
2 * [2136] Earliest Possible Day of Full Bloom
3 *
4 * You have n flower seeds. Every seed must be planted first before it can begin to grow, then bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed integer arrays plantTime and growTime, of length n each:
5 *
6 * plantTime[i] is the number of full days it takes you to plant the i^th seed. Every day, you can work on planting exactly one seed. You do not have to work on planting the same seed on consecutive days, but the planting of a seed is not complete until you have worked plantTime[i] days on planting it in total.
7 * growTime[i] is the number of full days it takes the i^th seed to grow after being completely planted. After the last day of its growth, the flower blooms and stays bloomed forever.
8 *
9 * From the beginning of day 0, you can plant the seeds in any order.
10 * Return the earliest possible day where all seeds are blooming.
11 *
12 * Example 1:
13 * <img alt="" src="https://assets.leetcode.com/uploads/2021/12/21/1.png" style="width: 453px; height: 149px;" />
14 * Input: plantTime = [1,4,3], growTime = [2,3,1]
15 * Output: 9
16 * Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
17 * One optimal way is:
18 * On day 0, plant the 0^th seed. The seed grows for 2 full days and blooms on day 3.
19 * On days 1, 2, 3, and 4, plant the 1^st seed. The seed grows for 3 full days and blooms on day 8.
20 * On days 5, 6, and 7, plant the 2^nd seed. The seed grows for 1 full day and blooms on day 9.
21 * Thus, on day 9, all the seeds are blooming.
22 *
23 * Example 2:
24 * <img alt="" src="https://assets.leetcode.com/uploads/2021/12/21/2.png" style="width: 454px; height: 184px;" />
25 * Input: plantTime = [1,2,3,2], growTime = [2,1,2,1]
26 * Output: 9
27 * Explanation: The grayed out pots represent planting days, colored pots represent growing days, and the flower represents the day it blooms.
28 * One optimal way is:
29 * On day 1, plant the 0^th seed. The seed grows for 2 full days and blooms on day 4.
30 * On days 0 and 3, plant the 1^st seed. The seed grows for 1 full day and blooms on day 5.
31 * On days 2, 4, and 5, plant the 2^nd seed. The seed grows for 2 full days and blooms on day 8.
32 * On days 6 and 7, plant the 3^rd seed. The seed grows for 1 full day and blooms on day 9.
33 * Thus, on day 9, all the seeds are blooming.
34 *
35 * Example 3:
36 *
37 * Input: plantTime = [1], growTime = [1]
38 * Output: 2
39 * Explanation: On day 0, plant the 0^th seed. The seed grows for 1 full day and blooms on day 2.
40 * Thus, on day 2, all the seeds are blooming.
41 *
42 *
43 * Constraints:
44 *
45 * n == plantTime.length == growTime.length
46 * 1 <= n <= 10^5
47 * 1 <= plantTime[i], growTime[i] <= 10^4
48 *
49 */
50pub struct Solution {}
51
52// problem: https://leetcode.com/problems/earliest-possible-day-of-full-bloom/
53// discuss: https://leetcode.com/problems/earliest-possible-day-of-full-bloom/discuss/?currentPage=1&orderBy=most_votes&query=
54
55// submission codes start here
56
57impl Solution {
58 pub fn earliest_full_bloom(plant_time: Vec<i32>, grow_time: Vec<i32>) -> i32 {
59 0
60 }
61}
62
63// submission codes end
64
65#[cfg(test)]
66mod tests {
67 use super::*;
68
69 #[test]
70 fn test_2136() {
71 }
72}
73
Back
© 2025 bowen.ge All Rights Reserved.