Medium

Quiz

#624 Maximum Distance in Arrays

APPROACH

You are given m sorted arrays. Choose exactly one element from each of two different arrays and compute |a - b|. Return the largest such absolute difference achievable.

Example 1:

Input: arrays = [[1,2,3],[4,5],[1,2,3]]
Output: 4
Explanation: One way to reach the maximum distance 4 is to pick 1 in the first or third array and pick 5 in the second array.

Example 2:

Input: arrays = [[1],[1]]
Output: 0
1 of 4
1:00

What is the optimal approach for this problem?