You are viewing a single comment's thread. Return to all comments →
RUST:
fn insertionSort1(n: i32, arr: &[i32]) { let mut result = arr.to_vec(); let number = result.pop().unwrap(); result.insert((n-1) as usize, *result.last().unwrap()); for idx in 1..=n { if idx < n && result[(n - idx -1) as usize] > number{ result[(n - idx) as usize] = result[((n - idx - 1)) as usize]; } else { result[(n-idx) as usize] = number; let strin = result.iter().map(|&x| x.to_string()).collect::<Vec<String>>().join(" "); println!("{}", strin); break; } let strin = result.iter().map(|&x| x.to_string()).collect::<Vec<String>>().join(" "); println!("{}", strin); } }
Seems like cookies are disabled on this browser, please enable them to open this website
Insertion Sort - Part 1
You are viewing a single comment's thread. Return to all comments →
RUST: