624. Maximum Distance in Arrays Medium
1/**
2 * [624] Maximum Distance in Arrays
3 *
4 * You are given m arrays, where each array is sorted in ascending order.
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 * Return the maximum distance.
7 *
8 * <strong class="example">Example 1:
9 *
10 * Input: arrays = [[1,2,3],[4,5],[1,2,3]]
11 * Output: 4
12 * 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.
13 *
14 * <strong class="example">Example 2:
15 *
16 * Input: arrays = [[1],[1]]
17 * Output: 0
18 *
19 *
20 * Constraints:
21 *
22 * m == arrays.length
23 * 2 <= m <= 10^5
24 * 1 <= arrays[i].length <= 500
25 * -10^4 <= arrays[i][j] <= 10^4
26 * arrays[i] is sorted in ascending order.
27 * There will be at most 10^5 integers in all the arrays.
28 *
29 */
30pub struct Solution {}
31
32// problem: https://leetcode.com/problems/maximum-distance-in-arrays/
33// discuss: https://leetcode.com/problems/maximum-distance-in-arrays/discuss/?currentPage=1&orderBy=most_votes&query=
34
35// submission codes start here
36
37impl Solution {
38 pub fn max_distance(arrays: Vec<Vec<i32>>) -> i32 {
39 0
40 }
41}
42
43// submission codes end
44
45#[cfg(test)]
46mod tests {
47 use super::*;
48
49 #[test]
50 fn test_624() {
51 }
52}
53
Back
© 2025 bowen.ge All Rights Reserved.