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: Vec<i32>) -> Vec<i32> {
- let mut not_trees: Vec<i32> = a.iter().filter(|x| **x > 0).map(|x| *x).collect();
- not_trees.sort();
- a.into_iter().map(|x| {
- if x > 0 {
- return not_trees.remove(0);
- }
- x
- }).collect::<Vec<_>>()
- }
Add Comment
Please, Sign In to add comment