diff options
Diffstat (limited to 'find-the-difference-of-two-arrays')
-rw-r--r-- | find-the-difference-of-two-arrays/Cargo.toml | 9 | ||||
-rw-r--r-- | find-the-difference-of-two-arrays/src/main.rs | 25 |
2 files changed, 34 insertions, 0 deletions
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<i32>, nums2: Vec<i32>) -> Vec<Vec<i32>> { + let mut a: Vec<i32> = Vec::new(); + let mut b: Vec<i32> = 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] + + } +} |