<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>

class Solution {
    int findMaxValue1(vector<int>arr) {
        int maxm = INT_MIN;
        int minm = INT_MAX;
        for(int i = 0; i < arr.size(); i++) {
            arr[i] = arr[i] + i;
            maxm = max(maxm, arr[i]);
           // cout<<maxm<<endl;
            minm = min(minm, arr[i]);
        }
        cout<<maxm<<" "<<minm<<endl;
        return maxm - minm;
    }
    int findMaxValue2(vector<int>arr) {
        int maxm = INT_MIN;
        int minm = INT_MAX;
        for(int i = 0; i < arr.size(); i++) {
            arr[i] = arr[i] - i;
            maxm = max(maxm, arr[i]);
           // cout<<maxm<<endl;
            minm = min(minm, arr[i]);
        }
       // cout<<maxm<<" "<<minm<<endl;
        return maxm - minm;
    }
public:
    int maxAbsValExpr(vector<int>& arr1, vector<int>& arr2) {
        vector<int>temp1;
        vector<int>temp2;
        vector<int>temp3;

        for(int i = 0; i < arr1.size(); i++) {
            temp1.push_back(arr1[i] + arr2[i]);
           // cout<<temp1[i]<<endl;
        }
        cout<<endl;

        for(int i = 0; i < arr1.size(); i++) {
            temp2.push_back(arr1[i] - arr2[i]);
           // cout<<temp2[i]<<endl;
        }
        cout<<endl;

        for(int i = 0; i < arr1.size(); i++) {
            temp3.push_back(arr2[i] - arr1[i]);
           // cout<<temp3[i]<<endl;
        }
        int res1 = max(findMaxValue1(temp1), findMaxValue2(temp1));
        int res2 = max(findMaxValue1(temp2), findMaxValue2(temp2));
        int res3 = max(findMaxValue1(temp3), findMaxValue2(temp3));
        return max(res1, max(res2, res3));
    }
};
33600