class Solution:
def intersection(self, nums1: List[int], nums2: List[int]) -> List[int]:
#法2 哈希表
#建立哈希表
hash_tmp={}
#存放结果的列表
res=[]
#遍历nums1,其值为hash的key,value统一都置为1
for i in nums1:
if not hash_tmp.get(i):
hash_tmp[i]=1
#遍历nums2,若其值能在hash中找到,则把hash中key对应的value置为0,把该值加入res
for j in nums2:
if hash_tmp.get(j):
res.append(j)
hash_tmp[j]=0
return res