**1732. 找到最高海拔(恢复差分)**

Untitled

public int largestAltitude(int[] gain) {
    int ans = 0;
    int h = 0;
    for(int x: gain) {
        h += x;
        ans = Math.max(ans, h);
    }
    return ans;
}

**724. 寻找数组的中心下标(两次前缀和)**

public int pivotIndex(int[] nums) {
    int n = nums.length;
    int[] left = new int[n + 1];
    int[] right = new int[n + 1];
    for(int i = 1; i <= n; i++) 
        left[i] = left[i - 1] + nums[i - 1];
    for(int i = n; i > 0; i--)
        right[i - 1] = right[i] + nums[i - 1];
    for(int i = 0; i < n; i++) {
        if(left[i] == right[i + 1]) return i;
    }
    return -1;
}