public int maxSubArray(int[] nums) {
        if (nums == null || nums.length == 0) return -1;
        int maxSum = Integer.MIN_VALUE, sum = 0;
        for (int n : nums) {
            sum = sum > 0 ? sum + n : n;
            maxSum = Math.max(maxSum, sum);
        }
        return maxSum;
    }