C++ and Python3 || Hashset || Simple and Optimal
\n\n# Code\nPython3 []\nclass Solution:\n    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:\n        set1 = set(nums1)\n      
> ![image.png](https://assets.leetcode.com/users/images/221a6a8a-6b51-470b-9478-90f840cb4a8d_1708848962.8635645.png)\n\n# Code\n```Python3 []\nclass Solution:\n    def findDifference(self, nums1: List[int], nums2: List[int]) -> List[List[int]]:\n        set1 = set(nums1)\n        set2 = set(nums2)\n        ans = [[], []]\n        for num in set1:\n            if num not in set2:\n                ans[0].append(num)\n        for num in set2:\n            if num not in set1:\n                ans[1].append(num)\n        return ans\n```\n```C++ []\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n        unordered_set<int> set1(nums1.begin(), nums1.end());\n        unordered_set<int> set2(nums2.begin(), nums2.end());\n        vector<vector<int>> ans(2);\n        for(auto num : set1) {\n            if(set2.contains(num) == false) ans[0].push_back(num);\n        }\n        for(auto num : set2) {\n            if(set1.contains(num) == false) ans[1].push_back(num);\n        }\n        return ans;\n    }\n};\n```
['Array', 'Hash Table', 'C++', 'Python3']