题意:
求两个数组的交集
利用set的特性
class Solution {
public:
vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
set<int> s1(nums1.begin(),nums1.end());
set<int> s2(nums2.begin(),nums2.end());
set<int>::iterator it;
vector<int> result;
for (it=s1.begin(); it!=s1.end(); ++it)
if(s2.count(*it) == 1) result.push_back(*it);
return result;
}
};