diff options
author | Orangerot <purple@orangerot.dev> | 2024-06-27 11:30:16 +0200 |
---|---|---|
committer | Orangerot <purple@orangerot.dev> | 2024-06-27 11:30:16 +0200 |
commit | 4b0a6a01b051a4ebfbc17661d14cb23fe4f275fb (patch) | |
tree | 0072cca328fe5adb2ed61004010228ff85e2164d /find-the-difference-of-two-arrays/src/main.rs |
Diffstat (limited to 'find-the-difference-of-two-arrays/src/main.rs')
-rw-r--r-- | find-the-difference-of-two-arrays/src/main.rs | 25 |
1 files changed, 25 insertions, 0 deletions
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] + + } +} |