본문 바로가기
Beakjoon&프로그래머스/Java

[LeetCode/Java] Find the Highest Altitude

by 현장 2025. 12. 31.

-Code

class Solution {
    public int largestAltitude(int[] gain) {
        int nowHeight = 0;
        int maxHegiht = 0;

        for (int height : gain) {
            nowHeight += height;
            maxHegiht = Math.max(maxHegiht, nowHeight);
        }

        return maxHegiht;
    }
}