Skip to content

Commit

Permalink
1732
Browse files Browse the repository at this point in the history
  • Loading branch information
isinsuarici committed Jan 19, 2022
1 parent 18f1484 commit 0f5766f
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions E_1732_FindtheHighestAltitude.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
public int largestAltitude(int[] gain) {
int[] result = new int[gain.length + 1];
int max = 0;
result[0] = 0;
for (int i = 0; i < gain.length - 1; i++) {
result[1] = gain[0];
if (result.length > 2)
result[i + 2] = result[i + 1] + gain[i + 1];
}
for (int j = 0; j < result.length; j++) {
if (result[j] > max) max = result[j];
}
return max;
}

0 comments on commit 0f5766f

Please sign in to comment.