Clean Code in C++


#1
vector<int> Solution::solve(vector<int> &a, vector<int> &b, vector<int> &c) {
    unordered_map<int,int> m1,m2,m3;
    unordered_set<int> s;
    for(int i : a) m1[i]++;
    for(int i : b) m2[i]++;
    for(int i : c) m3[i]++;
    vector<int> ans;
    for(int i : a) if(m2.count(i) || m3.count(i))s.insert(i);
    for(int i : b) if(m1.count(i) || m3.count(i))s.insert(i);
    for(int i : c) if(m1.count(i) || m2.count(i))s.insert(i);
    for(int i : s) ans.push_back(i);
    sort(ans.begin(),ans.end());
    return ans;
}