#624
Maximum Distance in Arrays
specialist · 940 · lc medium +32 · premium · verified · 45.6% accepted · 1,508 likes · top 29%
Description
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
Code
1
2
3