Crates.io | hidden-median |
lib.rs | hidden-median |
version | 0.1.3 |
source | src |
created_at | 2021-08-21 01:12:54.662285 |
updated_at | 2021-08-22 03:34:23.685094 |
description | Finds the median of two lists, when merged without breaking sorted state. |
homepage | |
repository | https://github.com/Inoshy/rust-book-helper/tree/master/problems/hidden-median |
max_upload_size | |
id | 440180 |
size | 17,939 |
Finds the hidden median of 2 sorted arrays in Olog(min(a, b))
time.
This crate works with both arrays and vectors. Also, I have avoided recursion
and while-loop for minimizing runtime strikes, instead used a plain for loop
that runs only Olog(min(a, b))
times.
In short, this is hidden_median
crate for you. lets look at a quick example!
use hidden_median::interface::Holder;
fn main() {
let list_a = [-3, -1, 5, 6];
let list_b = [-7, -2, 4, 8, 11];
let mut holder = Holder::new(&list_a, &list_b);
let result = holder.init().result();
// `result` is a tuple, that comes with a help text!
println!("{:?}", result);
// output: (4, 4, "median is a single number.")
}
Version Note: changed the readme