在两个列表中查找重复项<;int[]>;溪流
我有list个intarray.我需要使用2
个int数组列表来找到这些数组的副本.
我确实试图实现它,但我得到了一个空array.
keys = [[1,1,0], [0,0,1], [1,2,1], [1,3,1], [1,3,2]];
phaseKey = [[1,3,2], [1,2,1], [0,0,2], [1,2,3], [1,0,3]];
desired result: [[[1,3,2]], [1,2,1]];
My code:
Stream.concat(Stream.of(keys.stream().flatMapToInt(Arrays::stream)),
Stream.of(phaseKey.stream().flatMapToInt(Arrays::stream)))
.collect(Collectors.groupingBy(
Function.identity(),
Collectors.counting()))
.entrySet()
.stream()
.filter(m -> m.getValue() > 1)
.map(Map.Entry::getKey)
.toArray();