intersection of Three Sorted Arrays
给三个sorted array, 问里面的相交元素. 直接counting就可以.
class Solution {
public List<Integer> arraysIntersection(int[] arr1, int[] arr2, int[] arr3) {
int[] count = new int[2001];
for(int n : arr1)
count[n] ++;
for(int n : arr2)
count[n] ++;
for(int n : arr3)
count[n] ++;
List<Integer> res = new ArrayList<>();
for(int i = 0; i < count.length; i++){
if(count[i] == 3)
res.add(i);
}
return res;
}
}