1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-09-19 17:56:55 +02:00

rs: add “2215. Find the Difference of Two Arrays”

Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
Matej Focko 2024-01-11 23:30:28 +01:00
parent cece461197
commit be4de17b4d
Signed by: mfocko
GPG key ID: 7C47D46246790496

View file

@ -0,0 +1,13 @@
use std::collections::HashSet;
impl Solution {
pub fn find_difference(nums1: Vec<i32>, nums2: Vec<i32>) -> Vec<Vec<i32>> {
let nums1: HashSet<i32> = nums1.into_iter().collect();
let nums2: HashSet<i32> = nums2.into_iter().collect();
vec![
(&nums1 - &nums2).into_iter().collect(),
(&nums2 - &nums1).into_iter().collect(),
]
}
}