private int maxSubArrayHelper(int[] nums, int low, int high) {
        if (low > high) return Integer.MIN_VALUE;
        int mid = low + (high - low) / 2;
        int lmax = maxSubArrayHelper(nums, low, mid - 1);
        int rmax = maxSubArrayHelper(nums, mid + 1, high);

        int sum = 0;
        int lmmax = 0;
        for (int i = mid - 1; i >= low; --i) {
            sum += nums[i];
            if (sum > lmmax) lmmax = sum;
        }
        sum = 0;
        int rmmax = 0;
        for (int i = mid + 1; i <= high; ++i) {
            sum += nums[i];
            if (sum > rmmax) rmmax = sum;
        }
        return Math.max(lmmax + rmmax + nums[mid], Math.max(lmax, rmax));
    }