1732. 找到最高海拔

1732. 找到最高海拔

class Solution {
    public int largestAltitude(int[] gain) {
        int res = 0;
        int high = 0;
        for(int i = 0; i < gain.length; i ++) {
            high += gain[i];
            res = Math.max(res, high);
        }
        return res;
    }
}
posted @ 2022-11-19 16:49  Eiffelzero  阅读(24)  评论(0)    收藏  举报