parent
f161bda853
commit
c7f68825e7
|
|
@ -238,6 +238,25 @@ class Solution {
|
|||
}
|
||||
```
|
||||
|
||||
Rust:
|
||||
```rust
|
||||
use std::collections::HashSet;
|
||||
impl Solution {
|
||||
pub fn intersection(nums1: Vec<i32>, nums2: Vec<i32>) -> Vec<i32> {
|
||||
let mut resultSet: HashSet<i32> = HashSet::with_capacity(1000);
|
||||
let nums1Set: HashSet<i32> = nums1.into_iter().collect();
|
||||
|
||||
for num in nums2.iter() {
|
||||
if nums1Set.contains(num) {
|
||||
resultSet.insert(*num);
|
||||
}
|
||||
}
|
||||
|
||||
let ret: Vec<i32> = resultSet.into_iter().collect();
|
||||
ret
|
||||
}
|
||||
}
|
||||
```
|
||||
## 相关题目
|
||||
|
||||
* 350.两个数组的交集 II
|
||||
|
|
|
|||
Loading…
Reference in New Issue