一、原题
Given two arrays, write a function to compute their intersection.
Example:
Given nums1 = [1, 2, 2, 1], nums2 = [2, 2], return [2]
Note:
Each element in the result must be unique.
The result can be in any order.
二、思路
首先将数组1的元素放在set集合,然后遍历数组2,查看数组2的每一个元素是否包含在set集合中,若是在set中,则在set中移除(避免重复),在list集合中添加该元素,就取出了所有共同的元素。