vector<int> intersectionWithDuplicates(vector<int>& a, vector<int>& b) {
// code here
vector<int> res;
unordered_set<int> s(a.begin(), a.end());
for(int j = 0; j<b.size(); j++) {
if(s.find(b[j]) != s.end()) {
res.push_back(b[j]);
s.erase(b[j]);
}
}
return res;
}