Easy Solution Of JAVA 🔥C++🔥Using Set 🔥Beginner Friendly 🔥
\n\n# Code\nPLEASE UPVOTE IF YOU LIKE.\n\nclass Solution {\n    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {\n        List<List<Integer
\n\n# Code\nPLEASE UPVOTE IF YOU LIKE.\n```\nclass Solution {\n    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {\n        List<List<Integer>> ans = new ArrayList<List<Integer>>();\n        List<Integer> ans1 = new ArrayList<Integer>();\n        List<Integer> ans2 = new ArrayList<Integer>();\n        Set<Integer> set1 = new HashSet<Integer>();\n        Set<Integer> set2 = new HashSet<Integer>();        \n        \n        for(int n : nums1) set1.add(n);\n        for(int n : nums2) set2.add(n);\n        for (int n : set1){\n            if(set2.contains(n) == false){\n                ans1.add(n);\n            }\n        }\n        for (int n : set2){\n            if(set1.contains(n) == false){\n                ans2.add(n);\n            }\n        }\n        ans.add(ans1);\n        ans.add(ans2);\n        return ans;\n    }\n}\n```\nC++\n```\nclass Solution {\npublic:\n    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {\n\t\tvector<vector<int>> ans =  {{},{}};\n\t\t\n\t\t// Create set with elements of the vector\n        unordered_set<int> s1(nums1.begin(),nums1.end());\n        unordered_set<int> s2(nums2.begin(),nums2.end());\n        \n\t\t// For every element in set A that is not present in set B\n\t\t// Add it to the answer, do this for both set\n        for(auto x : s1) if(!s2.count(x)) ans[0].push_back(x);\n        for(auto x : s2) if(!s1.count(x)) ans[1].push_back(x);\n\t\t\n        return ans;\n    }\n};\n```
['C++', 'Java']