Missing Numbers

  • + 0 comments

    Here is my c++ solution, you can watch the explanation here : https://youtu.be/6AXUA5_XwUw

    vector<int> missingNumbers(vector<int> arr, vector<int> brr) {
        map<int, int> mp;
        for(int i = 0; i < brr.size(); i++) mp[brr[i]]++;
        for(int i = 0; i < arr.size(); i++) mp[arr[i]]--;
        map<int, int>::iterator it;
        vector<int> result;
        for(it = mp.begin(); it != mp.end(); it++)
            if(it->second > 0) result.push_back(it->first);
        
        return result;
    }