有没有办法找到多个列出了常见的元素呢?

有没有办法找到多个列出了常见的元素呢?

问题描述:

我有整型数组列表。我需要找到那些之间的共同之处。我能想到的是什么是 共同要素在两个列表中所列的延伸

I have a list of integer arrays. I need to find the common elements between those. What I can think of is an extension of what is listed in Common elements in two lists

Example would be 
[1,3,5],
[1,6,7,9,3],
[1,3,10,11]

should result in [1,3]

里有数组没有重复以及

有没有一种简单的方法来做到这一点?

Is there a straight forward way to do this?

您可以转换列表来台,然后用 Set.retainAll 方法不同之间的交叉集。
一旦你所有的相交集,你会留下共同的元素,您可以将结果集返回到列表中。

You can transform the lists to sets, and then use Set.retainAll method for intersection between the different sets. Once you intersect all sets, you are left with the common elements, and you can transform the resulting set back to a list.