🔥97% ✅Beats  | |    🚀only using HashSet 🧠  | |  💚Friendly🙌
\n Describe your first thoughts on how to solve this problem. \n\n# Approach\n### 1. Create HashSets:\n Create two HashSet objects (s1 and s2) to store the uniq
\n<!-- Describe your first thoughts on how to solve this problem. -->\n\n# Approach\n### 1. Create HashSets:\n Create two HashSet objects (s1 and s2) to store the unique elements of nums1 and nums2, respectively.\n\n### 2. Populate HashSets:\n Iterate through each element of nums1 and nums2 and add them to the corresponding HashSet.\n\n### 3. Create Lists from HashSets: \nCreate two ArrayList objects (lst1 and lst2) by converting the elements of s1 and s2 to lists.\n\n### 4. Find the Symmetric Difference: \nUse the removeAll method to find the symmetric difference. lst1.removeAll(s2) removes all elements from lst1 that are also present in s2, and lst2.removeAll(s1) removes all elements from lst2 that are also present in s1.\n\n### 5. Create Result List: \nCreate a list (lst) to store the two lists representing the symmetric difference. Add lst1 and lst2 to lst.\n\n### 6. Return Result:\n Return the final list lst as the result.\n<!-- Describe your approach to solving the problem. -->\n\n# Complexity\n- Time complexity: **O(N+M)**\n<!-- Add your time complexity here, e.g. $$O(n)$$ -->\n\n- Space complexity: **O(N+M)**\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        HashSet<Integer> s1 = new HashSet<>();\n        HashSet<Integer> s2 = new HashSet<>();\n        \n        for(int ele : nums1){\n            s1.add(ele);   \n        }\n        for(int ele : nums2){\n           s2.add(ele);\n        }\n        \n        List<List<Integer>> lst = new ArrayList<>();\n        List<Integer> lst1 = new ArrayList<>(s1);\n        List<Integer> lst2 = new ArrayList<>(s2);\n        lst1.removeAll(s2);\n        lst2.removeAll(s1);\n        lst.add(lst1);\n        lst.add(lst2);\n        return lst;\n    }\n}\n```\n![WhatsApp Image 2023-12-03 at 12.33.52.jpeg](https://assets.leetcode.com/users/images/30f541d2-a01d-4bbc-8281-bd8acfb6b866_1702288914.4701035.jpeg)\n
['Array', 'Hash Table', 'Java']