- alias:
- parent :: [[algo-哈希]]
- siblings ::
- child :: [[Integer list or set convert to int array]]
- refs: https://leetcode.cn/problems/intersection-of-two-arrays/
class Solution {
public int[] intersection(int[] nums1, int[] nums2) {
Set<Integer> set = new HashSet<>();
for (int num : nums1) {
set.add(num);
}
Set<Integer> result = new HashSet<>();
for (int num : nums2) {
if (set.contains(num)) {
result.add(num);
}
}
// Integer List or Set to int array
return result.stream().mapToInt(Integer::intValue).toArray();
}
}