Maximum Sum Score of Array

给一个array, 求每个index前边所有数的和和后边所有数字的和的最大值.

class Solution {
    public long maximumSumScore(int[] nums) {
        long sum = 0;
        for(int n : nums)
            sum += n;
        long res = Long.MIN_VALUE / 2;
        long pre = 0;
        for(int n : nums){
            pre += n;
            res = Math.max(res, Math.max(pre,sum));
            sum -= n;
        }
        return res;
    }
}