Skip to content

Commit 418cfa5

Browse files
committed
Add solution for Maximum Distance in Arrays
1 parent a503408 commit 418cfa5

File tree

2 files changed

+26
-0
lines changed

2 files changed

+26
-0
lines changed

Diff for: LeetCode/Maximum-Distance-in-Arrays/README.md

+23
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
# Maximum Distance in Arrays
2+
3+
Can you solve this real interview question? Maximum Distance in Arrays - You are given m arrays, where each array is sorted in ascending order.
4+
5+
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|.
6+
7+
Return the maximum distance.
8+
9+
 
10+
11+
Example 1:
12+
13+
14+
Input: arrays = [[1,2,3],[4,5],[1,2,3]]
15+
Output: 4
16+
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.
17+
18+
19+
Example 2:
20+
21+
22+
Input: arrays = [[1],[1]]
23+
Output: 0

Diff for: LeetCode/Maximum-Distance-in-Arrays/Solution.ext

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Input: arrays = [[1,2,3],[4,5],[1,2,3]]
2+
Output: 4
3+
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.

0 commit comments

Comments
 (0)