Given two arrays of integers with equal lengths, return the maximum value of:

|arr1[i] - arr1[j]| + |arr2[i] - arr2[j]| + |i - j|

where the maximum is taken over all 0 &lt;= i, j &lt; arr1.length.

&nbsp;
Example 1:

Input: arr1 = [1,2,3,4], arr2 = [-1,4,5,6]
Output: 13


Example 2:

Input: arr1 = [1,-2,-5,0,10], arr2 = [0,-2,-1,-7,-4]
Output: 20


&nbsp;
Constraints:


	2 &lt;= arr1.length == arr2.length &lt;= 40000
	-10^6 &lt;= arr1[i], arr2[i] &lt;= 10^6


class Solution(object):
    def maxAbsValExpr(self, arr1, arr2):
        """
        :type arr1: List[int]
        :type arr2: List[int]
        :rtype: int
        """
        max_ppp,max_ppm,max_pmp,max_pmm=float('-inf'),float('-inf'),float('-inf'),float('-inf')
        min_ppp,min_ppm,min_pmp,min_pmm=float('inf'),float('inf'),float('inf'),float('inf')
        for i,(a,b) in enumerate(zip(arr1,arr2)):
            ppp=a+b+i
            if ppp>max_ppp:max_ppp=ppp
            if ppp<min_ppp:min_ppp=ppp
            ppm=a+b-i
            if ppm>max_ppm:max_ppm=ppm
            if ppm<min_ppm:min_ppm=ppm
            pmp=a-b+i
            if pmp>max_pmp:max_pmp=pmp
            if pmp<min_pmp:min_pmp=pmp
            pmm=a-b-i
            if pmm>max_pmm:max_pmm=pmm
            if pmm<min_pmm:min_pmm=pmm
        return max(max_ppp-min_ppp,max_ppm-min_ppm,max_pmp-min_pmp,max_pmm-min_pmm)   
class Solution {
    public int maxAbsValExpr(int[] arr1, int[] arr2) {

        //1. remove the modulas -
        //i & j are interchangable because they are inside the modulas
        // A[i] - A[j] + B[i] -B[j] + i-j
        // A[i] + B[i] + i - B[j] - A[j] - j
        // (A[i] + B[i] + i) ->X
        // (B[j] - A[j] - j) -> y
        // X - Y;
        //to get max value X should be max & Y should min

        // Possible cases (Since both arrays have same number of indexes, we can use single for loop & i as index)
        //A[i] + B[i] + i ->1
        //A[i] - B[i] + i ->2
        //A[i] + B[i] - i ->3
        //A[i] - B[i] - i ->4

        // Find out max of all response

        int arrayLength =arr1.length;
        int v1[] = new int [arrayLength];
        int v2[] = new int [arrayLength] ;
        int v3[] = new int [arrayLength] ;
        int v4[] = new int [arrayLength] ;
        int res = 0;
        for(int i = 0 ; i< arrayLength; i++)
        {
            v1[i] = i + arr1[i] + arr2[i];
            v2[i] = i + arr1[i] - arr2[i];
            v3[i] = i - arr1[i] + arr2[i];
            v4[i] = i - arr1[i] - arr2[i];
        }
res = Math.max(res,Arrays.stream(v1).max().getAsInt()-Arrays.stream(v1).min().getAsInt());
                res = Math.max(res,Arrays.stream(v2).max().getAsInt()-Arrays.stream(v2).min().getAsInt());
                res = Math.max(res,Arrays.stream(v3).max().getAsInt()-Arrays.stream(v3).min().getAsInt());
                res = Math.max(res,Arrays.stream(v4).max().getAsInt()-Arrays.stream(v4).min().getAsInt());
    return res;
    }
}
class Solution {
public:
    int maxAbsValExpr(vector<int>& arr1, vector<int>& arr2) {
        int res=0;
        int n = arr1.size();
        vector<int>v1;
        vector<int>v2;
        vector<int>v3;
        vector<int>v4;
        for(int i=0;i<n;i++)
        {
            v1.push_back(i+arr1[i]+arr2[i]);
            v2.push_back(i+arr1[i]-arr2[i]);
            v3.push_back(i-arr1[i]+arr2[i]);
            v4.push_back(i-arr1[i]-arr2[i]);
        }
        res = max(res,*max_element(v1.begin(),v1.end())-*min_element(v1.begin(),v1.end()));
        res = max(res,*max_element(v2.begin(),v2.end())-*min_element(v2.begin(),v2.end()));
        res = max(res,*max_element(v3.begin(),v3.end())-*min_element(v3.begin(),v3.end()));
        res = max(res,*max_element(v4.begin(),v4.end())-*min_element(v4.begin(),v4.end()));
        return res;
    }
};
var maxAbsValExpr = function(arr1, arr2) {
    const l1 = [], l2 = [], l3 = [], l4 = [], res = [];
    
    for (let i = 0; i < arr1.length; i++) {
        l1.push(arr1[i] + arr2[i] + i)
        l2.push(arr1[i] - arr2[i] + i)
        l3.push(-arr1[i] + arr2[i] + i)
        l4.push(-arr1[i] - arr2[i] + i)
    }
    
    res.push(Math.max(...l1) - Math.min(...l1))
    res.push(Math.max(...l2) - Math.min(...l2))
    res.push(Math.max(...l3) - Math.min(...l3))
    res.push(Math.max(...l4) - Math.min(...l4))
    
    return Math.max(...res);
};
Maximum of Absolute Value Expression