<p>Given two arrays of integers with equal lengths, return the maximum value of:</p>

<p><code>|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|</code></p>

<p>where the maximum is taken over all <code>0 &lt;= i, j &lt; arr1.length</code>.</p>

<p>&nbsp;</p>
<p><strong class="example">Example 1:</strong></p>

<pre>
<strong>Input:</strong> arr1 = [1,2,3,4], arr2 = [-1,4,5,6]
<strong>Output:</strong> 13
</pre>

<p><strong class="example">Example 2:</strong></p>

<pre>
<strong>Input:</strong> arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4]
<strong>Output:</strong> 20
</pre>

<p>&nbsp;</p>
<p><strong>Constraints:</strong></p>

<ul>
	<li><code>2 &lt;= arr1.length == arr2.length &lt;= 40000</code></li>
	<li><code>-10^6 &lt;= arr1[i], arr2[i] &lt;= 10^6</code></li>
</ul>

#include <vector>
#include <algorithm>

using namespace std;

class Solution {
public:
    int maxAbsValExpr(vector<int>& arr1, vector<int>& arr2) {
        vector<int> ar1, ar2, ar3, ar4;
        int v1, v2, v3, v4;

        int res;

        for (int i = 0; i < arr1.size(); i++) {
            v1 = arr1[i] + arr2[i] + i;
            v2 = arr1[i] - arr2[i] + i;
            v3 = -arr1[i] + arr2[i] + i;
            v4 = -arr1[i] - arr2[i] + i;
            ar1.push_back(v1);
            ar2.push_back(v2);
            ar3.push_back(v3);
            ar4.push_back(v4);
        }
 res = 0;
            res = max(res, *max_element(ar1.begin(), ar1.end()) - *min_element(ar1.begin(), ar1.end()));
            res = max(res, *max_element(ar2.begin(), ar2.end()) - *min_element(ar2.begin(), ar2.end()));
            res = max(res, *max_element(ar3.begin(), ar3.end()) - *min_element(ar3.begin(), ar3.end()));
            res = max(res, *max_element(ar4.begin(), ar4.end()) - *min_element(ar4.begin(), ar4.end()));
        return res;
    }
};
31900