1
0
Fork 0
mirror of https://gitlab.com/mfocko/LeetCode.git synced 2024-11-10 00:09:06 +01:00
LeetCode/rs/find-the-difference-of-two-arrays.rs
Matej Focko be4de17b4d
rs: add “2215. Find the Difference of Two Arrays”
Signed-off-by: Matej Focko <mfocko@redhat.com>
2024-01-11 23:30:28 +01:00

13 lines
393 B
Rust

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(),
]
}
}