rs: add “2215. Find the Difference of Two Arrays”
Signed-off-by: Matej Focko <mfocko@redhat.com>
This commit is contained in:
parent
cece461197
commit
be4de17b4d
1 changed files with 13 additions and 0 deletions
13
rs/find-the-difference-of-two-arrays.rs
Normal file
13
rs/find-the-difference-of-two-arrays.rs
Normal 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(),
|
||||
]
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue