diff --git a/rs/find-the-difference-of-two-arrays.rs b/rs/find-the-difference-of-two-arrays.rs new file mode 100644 index 0000000..655b0fe --- /dev/null +++ b/rs/find-the-difference-of-two-arrays.rs @@ -0,0 +1,13 @@ +use std::collections::HashSet; + +impl Solution { + pub fn find_difference(nums1: Vec, nums2: Vec) -> Vec> { + let nums1: HashSet = nums1.into_iter().collect(); + let nums2: HashSet = nums2.into_iter().collect(); + + vec![ + (&nums1 - &nums2).into_iter().collect(), + (&nums2 - &nums1).into_iter().collect(), + ] + } +}