链接:
代码:
class Solution {
public:
vector<int> intersection(vector<int>& nums1, vector<int>& nums2) {
bool hash[1001] = { };
vector<int> ret;
for(auto a : nums1)
{
hash[a] = true;
}
for(auto b : nums2)
{
if(hash[b])
{
ret.push_back(b);
hash[b] = false;
}
}
return ret;
}
};
思路:
hash查找