# Leetcode 349. Intersection of Two Arrays

## 2. Solution

• Version 1
```class Solution:
def intersection(self, nums1, nums2):
result = set()
for x in nums1:
if x in nums2:
return list(result)```
• Version 2
```class Solution:
def intersection(self, nums1, nums2):
result = set()
stat = {}
for x in nums1:
stat[x] = x

for x in nums2:
if x in stat:

return list(result)```
• Version 3
```class Solution:
def intersection(self, nums1, nums2):
return list(set(nums1) & set(nums2))```

## Reference

1. https://leetcode.com/problems/intersection-of-two-arrays/

0 条评论

• ### LeetCode 349. Intersection of Two Arrays题目代码代码

样例 nums1 = [1, 2, 2, 1], nums2 = [2, 2], 返回 [2].

• ### 每天一算：Intersection of Two Arrays

leetcode上第349号问题：Intersection of Two Arrays

• ### 349. 两个数组的交集

来源：力扣（LeetCode） 链接：https://leetcode-cn.com/problems/intersection-of-two-arrays 著...

• ### 【LeetCode 136】 关关的刷题日记33 Intersection of Two

关关的刷题日记33 – Leetcode 349. Intersection of Two Arrays 题目 Given two arrays, write ...

• ### 【LeetCode 136】 关关的刷题日记34 Intersection of Two Arrays II

关关的刷题日记34 – Leetcode 350. Intersection of Two Arrays II 题目 Given two arrays, wri...

• ### LeetCode 349：两个数组的交集 Intersection of Two Arrays

Given two arrays, write a function to compute their intersection.

• ### Golang Leetcode 349. Intersection of Two Arrays.go

版权声明：原创勿转 https://blog.csdn.net/anakinsun/article/details/89088980

• ### Leetcode 350. Intersection of Two Arrays II

文章作者：Tyan 博客：noahsnail.com | CSDN | 简书