Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // This function is supposed to sort all non negative numbers in the indeces
- // that all non negative numbers are originally found
- fn sortByHeight(a: &mut Vec<i32>) {
- let mut not_negative: Vec<i32> = a.clone();
- not_negative.retain(|x| *x > 0);
- not_negative.sort();
- not_negative.reverse();
- for x in a {
- if *x > 0 {
- *x = not_negative.pop().unwrap();
- }
- }
- }
- fn main() {}
Add Comment
Please, Sign In to add comment