题解 | #两个数组的交集#
两个数组的交集
https://www.nowcoder.com/practice/56ea71d1f4e94de2aaec10e985874cce
class Solution { bool hash[1010] = {0}; public: vector<int> intersection(vector<int>& nums1, vector<int>& nums2) { vector<int> ret; for(auto x : nums1) { hash[x] = true; } for(auto x : nums2) { if(hash[x]) { ret.push_back(x); hash[x] = false; } } return ret; } };