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 <= i, j < arr1.length.
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
Constraints:
2 <= arr1.length == arr2.length <= 40000
-10^6 <= arr1[i], arr2[i] <= 10^6
class Solution:
    def maxAbsValExpr(self, arr1: List[int], arr2: List[int]) -> int:
        A, B, C, D = [], [], [], []
        # https://leetcode.com/problems/maximum-of-absolute-value-expression/discuss/340075/c++-beats-100-(both-time-and-memory)-with-algorithm-and-image 
        # much easier to understand.
        # we need to break the four absolute value and reduce them. We can see there are 8 cases but only 4 cases. We generate 4 arrays and compute max() - min()
        for i in range(len(arr1)):
            x = arr1[i] + arr2[i] + i
            y = arr1[i] - arr2[i] - i
            z = arr1[i] + arr2[i] - i
            t = arr1[i] - arr2[i] + i
            A.append(x)
            B.append(y)
            C.append(z)
            D.append(t)
        
        return max(list([max(x) - min(x) for x in [A, B, C, D]]))

class Solution:
    def maxAbsValExpr(self, arr1: List[int], arr2: List[int]) -> int:
        A, B, C, D = [], [], [], []
        # https://leetcode.com/problems/maximum-of-absolute-value-expression/discuss/340075/c++-beats-100-(both-time-and-memory)-with-algorithm-and-image 
        # much easier to understand.
        # we need to break the four absolute value and reduce them. We can see there are 8 cases but only 4 cases. We generate 4 arrays and compute max() - min()
        for i in range(len(arr1)):
            x = arr1[i] + arr2[i] + i
            y = arr1[i] - arr2[i] - i
            z = arr1[i] + arr2[i] - i
            t = arr1[i] - arr2[i] + i
            A.append(x)
            B.append(y)
            C.append(z)
            D.append(t)
        
        return max(list([max(x) - min(x) for x in [A, B, C, D]]))
