2
public List<List<Integer>> findDifference(int[] nums1, int[] nums2) {3
Set<Integer> set1 = new HashSet<>(); // create 2 hashsets4
Set<Integer> set2 = new HashSet<>();5
for (int num : nums1) {7
} // add nums1 elements to set18
for (int num : nums2) {10
} // add nums2 elements to set212
List<List<Integer>> resultList =13
new ArrayList<>(); // Initialize result list with 2 empty sublists that we will return14
resultList.add(new ArrayList<>());15
resultList.add(new ArrayList<>());17
for (int num : set1) { // just iterate to all elements of set118
if (!set2.contains(num)) {19
resultList.get(0).add(num);20
} // add those elements to first sublist of result list, which are not in set2.22
for (int num : set2) { // just iterate to all elements of set223
if (!set1.contains(num)) {24
resultList.get(1).add(num);25
} // add those elements to first sublist of result list, which are not in set1