//求两个数组的交集
public static String[] intersect(String[] arr1, String[] arr2) {
Map
LinkedList
for (String str : arr1) {
if (!map.containsKey(str)) {
map.put(str, Boolean.FALSE);
}
}
for (String str : arr2) {
if (map.containsKey(str)) {
map.put(str, Boolean.TRUE);
}
}
for (Entry
if (e.getValue().equals(Boolean.TRUE)) {
list.add(e.getKey());
}
}
String[] result = {};
return list.toArray(result);
}
两次 求交集, 再用Arrays.equals比较是否相等
做一个三重循环 三个数组都有的数字加到的d[]中就好了