Skip to content

Commit 9b0df17

Browse files
authored
Create 1732-find-the-highest-altitude.js
1 parent 1f748aa commit 9b0df17

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

1732-find-the-highest-altitude.js

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
/**
2+
* @param {number[]} gain
3+
* @return {number}
4+
*/
5+
const largestAltitude = function(gain) {
6+
const h = [0]
7+
for(let e of gain) {
8+
h.push(h[h.length - 1] + e)
9+
}
10+
let max = 0
11+
for(let e of h) {
12+
max = Math.max(max, e)
13+
}
14+
return max
15+
};

0 commit comments

Comments
 (0)