added description

This commit is contained in:
hendrik 2024-08-16 14:20:51 +02:00
parent cc59725603
commit d079f27ade
2 changed files with 43 additions and 0 deletions

3
Readme.md Normal file
View File

@ -0,0 +1,3 @@
Basically leet code challenges.
At some point i started categorizing
at some i even added the exercise description on top (at least most of the time)

View File

@ -1,3 +1,43 @@
/*
624. Maximum Distance in Arrays
Solved
Medium
Topics
Companies
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.
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
Constraints:
m == arrays.length
2 <= m <= 105
1 <= arrays[i].length <= 500
-104 <= arrays[i][j] <= 104
arrays[i] is sorted in ascending order.
There will be at most 105 integers in all the arrays.
*/
pub fn max_distance(arrays: Vec<Vec<i32>>) -> i32 {
let mut first_min : Option<(usize, i32)> = None;
let mut second_min : Option<(usize, i32)>= None;