From 4b0a6a01b051a4ebfbc17661d14cb23fe4f275fb Mon Sep 17 00:00:00 2001 From: Orangerot Date: Thu, 27 Jun 2024 11:30:16 +0200 Subject: Initial commit --- find-the-difference-of-two-arrays/Cargo.toml | 9 +++++++++ find-the-difference-of-two-arrays/src/main.rs | 25 +++++++++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 find-the-difference-of-two-arrays/Cargo.toml create mode 100644 find-the-difference-of-two-arrays/src/main.rs (limited to 'find-the-difference-of-two-arrays') diff --git a/find-the-difference-of-two-arrays/Cargo.toml b/find-the-difference-of-two-arrays/Cargo.toml new file mode 100644 index 0000000..d44a464 --- /dev/null +++ b/find-the-difference-of-two-arrays/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "find-the-difference-of-two-arrays" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +itertools = "0.9.0" diff --git a/find-the-difference-of-two-arrays/src/main.rs b/find-the-difference-of-two-arrays/src/main.rs new file mode 100644 index 0000000..a09cecb --- /dev/null +++ b/find-the-difference-of-two-arrays/src/main.rs @@ -0,0 +1,25 @@ +fn main() { + println!("Hello, world!"); +} + +struct Solution {} +impl Solution { + pub fn find_difference(nums1: Vec, nums2: Vec) -> Vec> { + let mut a: Vec = Vec::new(); + let mut b: Vec = Vec::new(); + + for i in nums1 { + if !nums2.contains(&i) && !nums1.contains(&i) { + a.push(i); + } + } + for i in nums2 { + if !nums2.contains(&i) && !nums1.contains(&i) { + b.push(i); + } + } + + vec![a,b] + + } +} -- cgit v1.2.3