Last active: 2 years ago
fn main() {
let nums = vec![1, 7, 24, 457, 435, 23, 55, 132, 66, 256, 0, 88, 5];
println!("Original vec: {:?}", nums);
println!("{:?}", find_mid_element(nums))
}
fn find_mid_element(v: Vec<i64>) -> String {
let mut sorted_nums = v;
sorted_nums.sort();
let mid_index = sorted_nums.len() / 2;
let mid = sorted_nums.get(mid_index).expect("cannot index");
format!("Vec: {:?}, mid element: {}", sorted_nums, mid)
}