summaryrefslogtreecommitdiff
path: root/find-the-difference-of-two-arrays
diff options
context:
space:
mode:
authorOrangerot <purple@orangerot.dev>2024-06-27 11:30:16 +0200
committerOrangerot <purple@orangerot.dev>2024-06-27 11:30:16 +0200
commit4b0a6a01b051a4ebfbc17661d14cb23fe4f275fb (patch)
tree0072cca328fe5adb2ed61004010228ff85e2164d /find-the-difference-of-two-arrays
Initial commitHEADmain
Diffstat (limited to 'find-the-difference-of-two-arrays')
-rw-r--r--find-the-difference-of-two-arrays/Cargo.toml9
-rw-r--r--find-the-difference-of-two-arrays/src/main.rs25
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]
+
+ }
+}