class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
Set<Integer> set = new HashSet<>();
for(int i = 0;i < nums1.length;i++){
for(int j = 0;j < nums2.length;j++){
if(nums1[i]==nums2[j])
set.add(nums1[i]);
}
}
int a = set.size();
int i = 0;
int []nums3 = new int[a];
for(int item:set){
nums3[i++] = item;
}
return nums3;
}
}