Given two 0-indexed integer arrays nums1 and nums2, return a list answer of size 2 where:


	answer[0] is a list of all distinct integers in nums1 which are not present in nums2.
	answer[1] is a list of all distinct integers in nums2 which are not present in nums1.


Note that the integers in the lists may be returned in any order.

&nbsp;
Example 1:

Input: nums1 = [1,2,3], nums2 = [2,4,6]
Output: [[1,3],[4,6]]
Explanation:
For nums1, nums1[1] = 2 is present at index 0 of nums2, whereas nums1[0] = 1 and nums1[2] = 3 are not present in nums2. Therefore, answer[0] = [1,3].
For nums2, nums2[0] = 2 is present at index 1 of nums1, whereas nums2[1] = 4 and nums2[2] = 6 are not present in nums2. Therefore, answer[1] = [4,6].

Example 2:

Input: nums1 = [1,2,3,3], nums2 = [1,1,2,2]
Output: [[3],[]]
Explanation:
For nums1, nums1[2] and nums1[3] are not present in nums2. Since nums1[2] == nums1[3], their value is only included once and answer[0] = [3].
Every integer in nums2 is present in nums1. Therefore, answer[1] = [].


&nbsp;
Constraints:


	1 &lt;= nums1.length, nums2.length &lt;= 1000
	-1000 &lt;= nums1[i], nums2[i] &lt;= 1000


class Solution(object):
    def findDifference(self, nums1, nums2):
        """
        :type nums1: List[int]
        :type nums2: List[int]
        :rtype: List[List[int]]
        """
        a = []
        for i in range(len(nums1)):
            if nums1[i] not in nums2:
                a.append(nums1[i])
        b = []
        for i in range(len(nums2)):
            if nums2[i] not in nums1:
                b.append(nums2[i])

        c = [list(set(a))] + [list(set(b))]

        return c
class Solution {
    public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {
        Set<Integer> set1 = new HashSet<>(); // create 2 hashsets
        Set<Integer> set2 = new HashSet<>();
        for(int num : nums1){ set1.add(num); } // add nums1 elements to set1
        for(int num : nums2){ set2.add(num); } // add nums2 elements to set2

        List<List<Integer>> resultList = new ArrayList<>(); // Initialize result list with 2 empty sublists that we will return
        resultList.add(new ArrayList<>());
        resultList.add(new ArrayList<>());

        for(int num : set1){ // just iterate to all elements of set1
            if(!set2.contains(num)){ resultList.get(0).add(num); } // add those elements to first sublist of result list, which are not in set2.
        }
        for(int num : set2){ // just iterate to all elements of set2
            if(!set1.contains(num)){ resultList.get(1).add(num); } // add those elements to first sublist of result list, which are not in set1
        }
        return resultList;
    }
}
class Solution {
public:
    vector<vector<int>> findDifference(vector<int>& nums1, vector<int>& nums2) {
	//unordered_set is implemented using a hash table where keys are hashed into indices of a hash table
	// all operations take O(1) on average
        unordered_set<int> n1;
        unordered_set<int> n2;
        for(int i=0;i<nums1.size();i++)
            n1.insert(nums1[i]);
        
        for(int i=0;i<nums2.size();i++)
            n2.insert(nums2[i]);
        
        vector<int> ans1;
		vector<vector<int>> ans;
        for(int x:n1)
        {
            if(n2.find(x)==n2.end())
                ans1.push_back(x);
        }
		ans.push_back(ans1);
		ans1.clear();
        for(int x:n2)
        {
            if(n1.find(x)==n1.end())
                ans1.push_back(x);
        }
        ans.push_back(ans1);
        return ans;
    }
};
var findDifference = function(nums1, nums2) {
    const s1 = new Set(nums1);
    const s2 = new Set(nums2);

    const a1 = [...s1].filter(x => !s2.has(x));
    const a2 = [...s2].filter(x => !s1.has(x));

    return [a1, a2];
};
Find the Difference of Two Arrays