코딩테스트

[leetcode] 1732. Find the Highest Altitude

nayoon 2024. 5. 18. 17:06

링크

class Solution {
    public int largestAltitude(int[] gain) {
        int start =0;
        int highest = 0;

        for(int i = 0; i < gain.length; i++) {
            start += gain[i];
            if (start > highest) {
                highest = start;
            }
        }

        return highest;
    }
}