Skip to content

Commit 403a32d

Browse files
authored
Create find-the-highest-altitude.py
1 parent c766769 commit 403a32d

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

Python/find-the-highest-altitude.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Time: O(n)
2+
# Space: O(1)
3+
4+
class Solution(object):
5+
def largestAltitude(self, gain):
6+
"""
7+
:type gain: List[int]
8+
:rtype: int
9+
"""
10+
result = curr = 0
11+
for g in gain:
12+
curr += g
13+
result = max(result, curr)
14+
return result

0 commit comments

Comments
 (0)