跳至主要內容

1732. 找到最高海拔

T4mako算法数组前缀和小于 1 分钟

1732. 找到最高海拔

简单

题目描述open in new window

class Solution {
    public int largestAltitude(int[] gain) {
        int res = 0;
        int high = 0;
        for (int i : gain) {
            high += i;
            res = Math.max(high,res);
        }
        return res;
    }
}
评论
  • 按正序
  • 按倒序
  • 按热度
Powered by Waline v2.15.5