HashSet | Beginners approach | Java solution
Complexity\n- Time complexity:  O(n)\n Add your time complexity here, e.g. O(n) \n\n- Space complexity: O(n)\n Add your space complexity here, e.g. O(n) \n\n# C
# Complexity\n- Time complexity:  $$O(n)$$\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: $$O(n)$$\n<!-- Add your space complexity here, e.g. $$O(n)$$ -->\n\n# Code\n```\nclass Solution {\n    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {\n\n        Set<Integer> set1=new HashSet<>();\n        Set<Integer> set2=new HashSet<>();\n        List<Integer> list1=new ArrayList<>();\n        List<Integer> list2=new ArrayList<>();\n        List<List<Integer>> ans=new ArrayList<>();\n\n        for(int e: nums1) set1.add(e);\n        for(int e: nums2) set2.add(e);\n\n        for(int e: set1) if(!set2.contains(e)) list1.add(e);\n        for(int e: set2) if(!set1.contains(e)) list2.add(e);\n\n        ans.add(list1);\n        ans.add(list2);\n\n        return ans;\n    }\n}\n```
['Java']