Zepruv › Coding problems

Maximum of Absolute Value Expression

Medium · Array, Math

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

Starter code (python)

class Solution(object):
    def maxAbsValExpr(self, arr1, arr2):
        """
        :type arr1: List[int]
        :type arr2: List[int]
        :rtype: int
        """
        

Related problems

Previous: Shortest Path with Alternating Colors · Next: Replace Elements with Greatest Element on Right Side · All problems

Zepruv is a technical interview practice platform. Read any problem for free; sign in to run your code, submit and keep your progress.