Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit 8642961

Browse files
authoredNov 22, 2020
Update 1665-minimum-initial-energy-to-finish-tasks.js
1 parent 54760c5 commit 8642961

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed
 

‎1665-minimum-initial-energy-to-finish-tasks.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,18 @@
1+
/**
2+
* @param {number[][]} tasks
3+
* @return {number}
4+
*/
5+
const minimumEffort = function (tasks) {
6+
tasks.sort((a, b) => a[1] - a[0] > b[1] - b[0] ? 1 : -1)
7+
let res = 0
8+
for(let e of tasks) {
9+
res = Math.max(res + e[0], e[1])
10+
}
11+
return res
12+
}
13+
14+
// another
15+
116
/**
217
* @param {number[][]} tasks
318
* @return {number}

0 commit comments

Comments
 (0)
Please sign in to comment.