image_2021-10-16_18-07-09.png
32.6 KB
#N1732 Find the Highest Altitude
problem link=>https://leetcode.com/problems/find-the-highest-altitude/
#solution
problem link=>https://leetcode.com/problems/find-the-highest-altitude/
#solution
class Solution {
public int largestAltitude(int[] gain) {
int max=0, altitude=0;
for(int i=0; i<gain.length; i++){
altitude+=gain[i];
gain[i]=altitude;
max=Math.max(max, gain[i]);
}
return max;
}
}