Created
April 19, 2021 03:52
-
-
Save ashleighbasil/3c2caf786e92a9bafae1b97024be895b to your computer and use it in GitHub Desktop.
Cassidoo move zeroes solution :3
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fn move_zeroes(arr: &mut Vec<i32>) -> Vec<i32> { | |
arr.sort_by_key(|n: &i32| n == &0); | |
arr.to_vec() | |
} | |
// How to use it: | |
fn main() { | |
let mut xs: Vec<i32> = vec![1, 0, 0, 5, 3, 0]; | |
move_zeroes(&mut xs); | |
println!("{:?}", xs); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment