#pragma once #include namespace set_util { template std::unordered_set intersection(std::unordered_set set1, std::unordered_set set2) { if (set2.size() < set1.size()) { auto temp = set1; set1 = set2; set2 = temp; } std::unordered_set m(set1.begin(), set1.end()); std::unordered_set res; for (auto a : set2) if (m.count(a)) { res.insert(a); m.erase(a); } return res; } } // namespace set_util