forked from aylei/leetcode-rust
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathn0004_median_of_two_sorted_arrays.rs
59 lines (54 loc) · 1.02 KB
/
n0004_median_of_two_sorted_arrays.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
/**
* [4] Median of Two Sorted Arrays
*
* There are two sorted arrays nums1 and nums2 of size m and n respectively.
*
* Find the median of the two sorted arrays. The overall run time complexity should be O(log (m+n)).
*
* You may assume nums1 and nums2 cannot be both empty.
*
* Example 1:
*
*
* nums1 = [1, 3]
* nums2 = [2]
*
* The median is 2.0
*
*
* Example 2:
*
*
* nums1 = [1, 2]
* nums2 = [3, 4]
*
* The median is (2 + 3)/2 = 2.5
*
*
*/
pub struct Solution {}
// submission codes start here
// TODO: nth slice
impl Solution {
pub fn find_median_sorted_arrays(nums1: Vec<i32>, nums2: Vec<i32>) -> f64 {
1.0
}
}
// submission codes end
#[cfg(test)]
mod tests {
use super::*;
// TODO: implementation
#[test]
#[ignore]
fn test_4() {
assert_eq!(
Solution::find_median_sorted_arrays(vec![1, 3], vec![2]),
2.0
);
assert_eq!(
Solution::find_median_sorted_arrays(vec![1, 2], vec![3, 4]),
2.5
);
}
}