Java Two Sets Solution - O(N)
\nclass Solution {\n    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {\n        List<List<Integer>> result = new ArrayList<>();\n        
```\nclass Solution {\n    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {\n        List<List<Integer>> result = new ArrayList<>();\n        \n\t\t// Initialize each array as a set\n        Set<Integer> list1 = new HashSet<>();\n        for (int n : nums1) {\n            list1.add(n);\n        }\n        \n        Set<Integer> list2 = new HashSet<>();\n        for (int n : nums2) {\n            list2.add(n);\n        }\n        \n        List<Integer> unique1 = new ArrayList<>();\n        List<Integer> unique2 = new ArrayList<>();\n        \n\t\t// For each distinct number in array 1, we check if that number is contained in array 2.\n\t\t// If it is, we know that number is not unique to either set, therefore we can remove it from set 2.\n\t\t// If the number isn\'t found in set 2, we know it is unique to set 1, and we can add it to our result.\n        for (int n : list1) {\n            if (list2.contains(n)) {\n                list2.remove(n);\n            } else {\n                unique1.add(n);\n            }\n        }\n        \n\t\t// All remaining numbers in set 2 weren\'t in set 1, so they are uniqe to array 2.\n        for (int n : list2) {\n            unique2.add(n);\n        }\n        \n        result.add(unique1);\n        result.add(unique2);\n        \n        return result;\n    }\n}\n```\n\nUsing hashsets are perfect for this problem, as we can not only check if  a set contains a number in constant lookup time but also remove duplicates inherently. \n\nSteps:\n1) Build two sets out of our passed in arrays.\n2) Iterate through the first set. If the second set contains a number in the first set, we remove it from the second set (cause it is a dupe). Otherwise, we add it to our resulting list.\n3) All remaining numbers in the second set are unique to array 2, so we can add them to our result.\n\nHope this helps, let me know if I missed anything.
['Java']