Find the Highest Altitude

给一个数组, 从0开始,问最大多少.

class Solution {
    public int largestAltitude(int[] gain) {
        int res = 0;
        int cur = 0;
        for(int g : gain) {
            cur += g;
            res = Math.max(res, cur);
        }
        return res;
    }
}