Given a list, for example, L = {{1, 2, 4}, {8, 3, 5}, {5, 6, 8}, {1, 7, 4}}
, some of these sublists have common elements, such as {1, 2, 4} and {1, 7, 4}. I only need to find one pair. So, I have written the following code.
L = {{1, 2, 4}, {8, 3, 5}, {5, 6, 8}, {1, 7, 4}};
result = Select[Subsets[L, {2}], IntersectingQ[#[[1]], #[[2]]] &, 1]
But I feel like the function Subsets
(generating too many of them) is a bit overkill. In reality, we will quickly find them in my large list, and I only need to find one pair. I wonder if there is a better function to achieve this.