feat: 1470_shuffle_the_array
This commit is contained in:
parent
30a13831b7
commit
47e2090304
7
1470_shuffle_the_array/Cargo.lock
generated
Normal file
7
1470_shuffle_the_array/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 = "shuffle_the_array"
|
||||||
|
version = "0.1.0"
|
6
1470_shuffle_the_array/Cargo.toml
Normal file
6
1470_shuffle_the_array/Cargo.toml
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
[package]
|
||||||
|
name = "shuffle_the_array"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2024"
|
||||||
|
|
||||||
|
[dependencies]
|
11
1470_shuffle_the_array/src/lib.rs
Normal file
11
1470_shuffle_the_array/src/lib.rs
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
pub struct Solution;
|
||||||
|
|
||||||
|
impl Solution {
|
||||||
|
pub fn shuffle(mut nums: Vec<i32>, _: i32) -> Vec<i32> {
|
||||||
|
let right = nums.split_off(nums.len() / 2);
|
||||||
|
nums.iter()
|
||||||
|
.zip(right)
|
||||||
|
.flat_map(|(&x, y)| vec![x, y])
|
||||||
|
.collect()
|
||||||
|
}
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user