Vector Difference Finder C++
Intuition\nThe intuition is to find the elements that are present in one vector (nums1) but not in the other vector (nums2). \n\n# Approach\n1. Counting Occurre
# Intuition\nThe intuition is to find the elements that are present in one vector (nums1) but not in the other vector (nums2). \n\n# Approach\n1. Counting Occurrences: Two unordered_maps (m and mp) are used to count the occurrences of elements in nums1 and nums2 respectively.\n    This step helps identify which elements are unique to each vector.\n\n2. Identifying Unique Elements: Two vectors (v1 and v2) are initialized to store elements unique to nums2 and nums1 respectively. \n      This is achieved by iterating through one vector and checking if each element is present in the other vector\'s count map. If not, the element is added to the corresponding unique elements vector.\n\n3. Sorting and Removing Duplicates: Both v1 and v2 are sorted to prepare for removing duplicates. \n        The unique algorithm is then applied to remove consecutive duplicate elements from each vector.\n\n4. Constructing Result: The unique elements vectors (v1 and v2) are then pushed into a 2D vector res, where v1 represents elements unique to nums2 and v2 represents elements unique to nums1.\n\n         The 2D vector res containing the unique elements from both vectors is returned.\n\n# Complexity\n- Time complexity:\nO(n + m)\n\n- Space complexity:\nO(n + m)\n\n# Code\n```\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n        unordered_map<int,int>m;\n        unordered_map<int,int>mp;\n\n        for(int i=0;i<nums2.size();i++)\n        {\n            mp[nums2[i]]++;\n        }\n        vector<int>v2;\n        for(auto j:nums1)\n        {\n            if(mp.find(j)==mp.end())\n            {\n                v2.push_back(j);//nums1 values\n            }\n        }\n\n\n        for(int i=0;i<nums1.size();i++)\n        {\n            m[nums1[i]]++;\n        }\n        vector<int>v1;\n        for(auto j:nums2)\n        {\n            if(m.find(j)==m.end())\n            {\n                v1.push_back(j);//nums2 values\n            }\n        }\n    sort(v2.begin(),v2.end());\n    sort(v1.begin(),v1.end());\n    \n    v2.erase(unique(v2.begin(),v2.end()),v2.end());\n    v1.erase(unique(v1.begin(),v1.end()),v1.end());\n\n    vector<vector<int>>res;\n    res.push_back(v2);\n    res.push_back(v1);\n    \n    return res;\n    }\n};\n```
['Hash Table', 'C++']