diff --git a/problems/0349.两个数组的交集.md b/problems/0349.两个数组的交集.md index 153077ed..a6e07424 100644 --- a/problems/0349.两个数组的交集.md +++ b/problems/0349.两个数组的交集.md @@ -310,6 +310,22 @@ impl Solution { } ``` +解法2: + +```rust +use std::collections::HashSet; +impl Solution { + pub fn intersection(nums1: Vec, nums2: Vec) -> Vec { + nums1 + .into_iter() + .collect::>() + .intersection(&nums2.into_iter().collect::>()) + .copied() + .collect() + } +} +``` + C: ```C int* intersection1(int* nums1, int nums1Size, int* nums2, int nums2Size, int* returnSize){