C++ Solution || Two-Pointers || Unordered Set
Approach 1: Sorting + Two Pointers\nTime Complexity: max(O(NlogN), O(MlogM)), M, N are size of arrays\n\nclass Solution {\npublic:\n    vector<vector<int>> find
**Approach 1: Sorting + Two Pointers**\n**Time Complexity: max(O(NlogN), O(MlogM))***, M, N are size of arrays*\n```\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n        sort(nums1.begin(), nums1.end());\n        sort(nums2.begin(), nums2.end());\n        \n        vector<int> v1;\n        vector<int> v2;\n        \n        int n = nums1.size();\n        int m = nums2.size();\n        int i = 0;\n        int j = 0;\n        \n        while(i < n  &&  j < m){\n            while(i < n-1  &&  nums1[i] == nums1[i+1])\n                i++;\n            while(j < m-1  &&  nums2[j] == nums2[j+1])\n                j++;\n            if(nums1[i] < nums2[j])\n                v1.push_back(nums1[i++]);\n            else if(nums1[i] > nums2[j])\n                v2.push_back(nums2[j++]);\n            else{\n                i++;\n                j++;\n            }\n        }\n        \n        while(i < n){\n            while(i < n-1  &&  nums1[i] == nums1[i+1])\n                i++;\n            v1.push_back(nums1[i++]);\n        }\n        \n        while(j < m){\n            while(j < m-1  &&  nums2[j] == nums2[j+1])\n                j++;\n            v2.push_back(nums2[j++]);\n        }\n        \n        return {v1, v2};\n    }\n};\n```\n\n**Apporach 2: Using Unordered set**\n**Time Complexity: max(O(N), O(M))**\n```\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n        unordered_set<int> s1(nums1.begin(), nums1.end());\n        unordered_set<int> s2(nums2.begin(), nums2.end());\n        \n        vector<int> v1, v2;\n        for(auto num: s1)\n            if(!s2.count(num))\n                v1.push_back(num);\n        \n        for(auto num: s2)\n            if(!s1.count(num))\n                v2.push_back(num);\n        \n        return {v1, v2};\n    }\n};\n```\n\nDo upvote if this helps.
['Two Pointers', 'C', 'Ordered Set', 'C++']