feat: 3467_transform_array_by_parity
This commit is contained in:
parent
1e2a86cf52
commit
1aa56ff3c9
7
3467_transform_array_by_parity/Cargo.lock
generated
Normal file
7
3467_transform_array_by_parity/Cargo.lock
generated
Normal file
@ -0,0 +1,7 @@
|
||||
# This file is automatically @generated by Cargo.
|
||||
# It is not intended for manual editing.
|
||||
version = 4
|
||||
|
||||
[[package]]
|
||||
name = "transform_array_by_parity"
|
||||
version = "0.1.0"
|
6
3467_transform_array_by_parity/Cargo.toml
Normal file
6
3467_transform_array_by_parity/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
||||
[package]
|
||||
name = "transform_array_by_parity"
|
||||
version = "0.1.0"
|
||||
edition = "2024"
|
||||
|
||||
[dependencies]
|
10
3467_transform_array_by_parity/src/lib.rs
Normal file
10
3467_transform_array_by_parity/src/lib.rs
Normal file
@ -0,0 +1,10 @@
|
||||
pub struct Solution;
|
||||
|
||||
impl Solution {
|
||||
pub fn transform_array(nums: Vec<i32>) -> Vec<i32> {
|
||||
let even_count = nums.iter().filter(|&num| num % 2 == 0).count();
|
||||
let mut result = vec![0; even_count];
|
||||
result.extend(vec![1; nums.len() - even_count].iter());
|
||||
result
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user