Solution By Dare2Solve | Detailed Explanation | Clean Code
Explanation []\nauthorslog.com/blog/RUbuPJtkxb\n\n# Code\n\ncpp []\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector
```Explanation []\nauthorslog.com/blog/RUbuPJtkxb\n```\n# Code\n\n```cpp []\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n        set<int> set1(nums1.begin(), nums1.end());\n        set<int> set2(nums2.begin(), nums2.end());\n\n        vector<int> nums1Def;\n        for (int n : set1) {\n            if (set2.find(n) == set2.end()) {\n                nums1Def.push_back(n);\n            }\n        }\n\n        vector<int> nums2Def;\n        for (int n : set2) {\n            if (set1.find(n) == set1.end()) {\n                nums2Def.push_back(n);\n            }\n        }\n\n        return {nums1Def, nums2Def};\n    }\n};\n```\n\n```python []\nclass Solution:\n    def findDifference(self, nums1, nums2):\n        set1 = set(nums1)\n        set2 = set(nums2)\n\n        nums1Def = [n for n in set1 if n not in set2]\n        nums2Def = [n for n in set2 if n not in set1]\n\n        return [nums1Def, nums2Def]\n```\n\n```java []\nclass Solution {\n    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {\n        Set<Integer> set1 = new HashSet<>();\n        for (int n : nums1) {\n            set1.add(n);\n        }\n\n        Set<Integer> set2 = new HashSet<>();\n        for (int n : nums2) {\n            set2.add(n);\n        }\n\n        List<Integer> nums1Def = new ArrayList<>();\n        for (int n : set1) {\n            if (!set2.contains(n)) {\n                nums1Def.add(n);\n            }\n        }\n\n        List<Integer> nums2Def = new ArrayList<>();\n        for (int n : set2) {\n            if (!set1.contains(n)) {\n                nums2Def.add(n);\n            }\n        }\n\n        List<List<Integer>> result = new ArrayList<>();\n        result.add(nums1Def);\n        result.add(nums2Def);\n        return result;\n    }\n}\n```\n\n```javascript []\nvar findDifference = function (nums1, nums2) {\n    let set1 = new Set(nums1)\n    let set2 = new Set(nums2)\n\n    const nums1Def = []\n    for (let n of set1) {\n        if (!set2.has(n)) nums1Def.push(n)\n    }\n\n    const nums2Def = []\n    for (let n of set2) {\n        if (!set1.has(n)) nums2Def.push(n)\n    }\n    return [nums1Def, nums2Def]\n};\n```
['Hash Table', 'Python', 'C++', 'Java', 'Python3', 'JavaScript']