class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
if(nums1 == null || nums1.length == 0 || nums2 == null || nums2.length == 0){
return new int[0];
}
Set set1 = new HashSet<>();
Set resSet = new HashSet<>();
for(int i:nums1)
set1.add(i);
for(int i:nums2)
if(set1.contains(i))
resSet.add(i);
int[] resArr = new int[resSet.size()];
int index = 0;
for(int i:resSet)
resArr[index++] = i;
return resArr;
}
}



