Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Skip to content

Commit c77d264

Browse files
committed
Add solution #2136
1 parent 817fc0f commit c77d264

File tree

2 files changed

+41
-1
lines changed

2 files changed

+41
-1
lines changed

README.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# 1,770 LeetCode solutions in JavaScript
1+
# 1,771 LeetCode solutions in JavaScript
22

33
[https://leetcodejavascript.com](https://leetcodejavascript.com)
44

@@ -1637,6 +1637,7 @@
16371637
2133|[Check if Every Row and Column Contains All Numbers](./solutions/2133-check-if-every-row-and-column-contains-all-numbers.js)|Easy|
16381638
2134|[Minimum Swaps to Group All 1's Together II](./solutions/2134-minimum-swaps-to-group-all-1s-together-ii.js)|Medium|
16391639
2135|[Count Words Obtained After Adding a Letter](./solutions/2135-count-words-obtained-after-adding-a-letter.js)|Medium|
1640+
2136|[Earliest Possible Day of Full Bloom](./solutions/2136-earliest-possible-day-of-full-bloom.js)|Hard|
16401641
2140|[Solving Questions With Brainpower](./solutions/2140-solving-questions-with-brainpower.js)|Medium|
16411642
2145|[Count the Hidden Sequences](./solutions/2145-count-the-hidden-sequences.js)|Medium|
16421643
2154|[Keep Multiplying Found Values by Two](./solutions/2154-keep-multiplying-found-values-by-two.js)|Easy|
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
/**
2+
* 2136. Earliest Possible Day of Full Bloom
3+
* https://leetcode.com/problems/earliest-possible-day-of-full-bloom/
4+
* Difficulty: Hard
5+
*
6+
* You have n flower seeds. Every seed must be planted first before it can begin to grow, then
7+
* bloom. Planting a seed takes time and so does the growth of a seed. You are given two 0-indexed
8+
* integer arrays plantTime and growTime, of length n each:
9+
* - plantTime[i] is the number of full days it takes you to plant the ith seed. Every day, you can
10+
* work on planting exactly one seed. You do not have to work on planting the same seed on
11+
* consecutive days, but the planting of a seed is not complete until you have worked plantTime[i]
12+
* days on planting it in total.
13+
* - growTime[i] is the number of full days it takes the ith seed to grow after being completely
14+
* planted. After the last day of its growth, the flower blooms and stays bloomed forever.
15+
*
16+
* From the beginning of day 0, you can plant the seeds in any order.
17+
*
18+
* Return the earliest possible day where all seeds are blooming.
19+
*/
20+
21+
/**
22+
* @param {number[]} plantTime
23+
* @param {number[]} growTime
24+
* @return {number}
25+
*/
26+
var earliestFullBloom = function(plantTime, growTime) {
27+
const seeds = plantTime.map((plant, index) => ({ plant, grow: growTime[index] }));
28+
seeds.sort((a, b) => b.grow - a.grow);
29+
30+
let plantingDays = 0;
31+
let result = 0;
32+
33+
for (const { plant, grow } of seeds) {
34+
plantingDays += plant;
35+
result = Math.max(result, plantingDays + grow);
36+
}
37+
38+
return result;
39+
};

0 commit comments

Comments
 (0)