Skip to content

Commit ba06176

Browse files
authored
1732. Find the Highest Altitude
LC 75
1 parent e7a7fa3 commit ba06176

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

highestAltitude.cpp

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution {
2+
public:
3+
int largestAltitude(vector<int>& gain) {
4+
int maxAlt = 0;
5+
int prefixSum = 0;
6+
for (int i=0; i<gain.size(); i++){
7+
prefixSum += gain[i];
8+
maxAlt = max(prefixSum, maxAlt);
9+
}
10+
return maxAlt;
11+
}
12+
};

0 commit comments

Comments
 (0)