Skip to content

Commit 577bc69

Browse files
authored
Added Find the Highest Altitude.java
1 parent e312d85 commit 577bc69

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

Easy/Find the Highest Altitude.java

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

0 commit comments

Comments
 (0)