```
class Solution(object):
def intersect(self, nums1, nums2):
d = {}
for n in nums1:
d[n] = d.get(n, 0) + 1
ret = []
for n in nums2:
if d.get(n) > 0:
ret.append(n)
d[n] -= 1
return ret
```