public int maxTwoSubArrays(ArrayList<Integer> nums) {
        // write your code
        if (nums == null || nums.size() == 0)
            return 0;
        int n = nums.size();
        int[] left = new int[n];
        int[] right = new int[n];
        left[0] = nums.get(0);
        for (int i = 1; i < n; ++i) {
            int val = nums.get(i);
            left[i] = Math.max(left[i - 1] + val, val);
        }
        right[n - 1] = nums.get(n - 1);
        for (int i = n - 2; i >= 0; --i) {
            int val = nums.get(i);
            right[i] = Math.max(right[i + 1] + val, val);
        }
        int max = Integer.MIN_VALUE;
        for (int i = 0; i < n - 1; ++i) {
            for (int j = i + 1; j < n; ++j) {
                max = Math.max(max, left[i] + right[j]);
            }
        }
        return max;
    }