Skip to content

Practice Maximum Distance in Arrays

Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.

Medium#624
LeetCode Problem

Maximum Distance in Arrays

Problem Statement

You are given m arrays, where each array is sorted in ascending order. You can pick up two integers from two different arrays (each array picks one) and calculate the distance. We define the distance between two integers a and b to be their absolute difference |a - b|. Return the maximum distance.

Source: Maximum Distance in Arrays on LeetCode. Use the original task for its coding environment and submissions.

Examples

# Example 1

Input
arrays = [[1,2,3],[4,5],[1,2,3]]
Output
4

# Example 2

Input
arrays = [[1],[1]]
Output
0

Constraints

m == arrays.length
2 <= m <= 10^5
1 <= arrays[i].length <= 500
-10^4 <= arrays[i][j] <= 10^4
arrays[i] is sorted in ascending order.
There will be at most 10^5 integers in all the arrays.

Related LeetCode Problems

Practice more problems similar to Maximum Distance in Arrays.

Review your practice with PhantomCodeAI

After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.