Leetcode in Java && Oracle
422 subscribers
8 photos
397 files
400 links
Second channel: @codeforces_java

Let's Develop Together!
Download Telegram
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
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;
}
}