Skip to content

Commit 1f8cc21

Browse files
authored
Update 2136-earliest-possible-day-of-full-bloom.js
1 parent be895f6 commit 1f8cc21

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

2136-earliest-possible-day-of-full-bloom.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,28 @@
1+
/**
2+
* @param {number[]} plantTime
3+
* @param {number[]} growTime
4+
* @return {number}
5+
*/
6+
const earliestFullBloom = function(plantTime, growTime) {
7+
const n = plantTime.length, arr = Array(n)
8+
for(let i = 0; i < n; i++) {
9+
arr.push([growTime[i], plantTime[i]])
10+
}
11+
arr.sort((a, b) => b[0] - a[0])
12+
13+
let res = 0, cur = 0
14+
for(let i = 0; i < n; i++) {
15+
const e = arr[i]
16+
res = Math.max(res, cur + e[0] + e[1])
17+
cur += e[1]
18+
}
19+
20+
return res
21+
};
22+
23+
// another
24+
25+
126
/**
227
* @param {number[]} plantTime
328
* @param {number[]} growTime

0 commit comments

Comments
 (0)