im currently working on a code to group Arrays based on their Elements and i hope u can help me out with your wisdom.
I have given following Arrays:
List<String> list1 = new ArrayList<String>(Arrays.asList("A", "B", "C", "F", "I"));
List<String> list2 = new ArrayList<String>(Arrays.asList("B", "C", "D", "E", "F"));
List<String> list3 = new ArrayList<String>(Arrays.asList("J", "K", "B", "L", "F"));
List<String> list4 = new ArrayList<String>(Arrays.asList("L", "K", "D", "C", "J"));
Now i want to compare which of these lists have 3 Elements in common and save that ListNames in a new List/Array.
commonList1{List2, List3,} - (B,C,F)
commonList4{List5} - (K,J,L)
Has anyone a smarter idea for doing that, instead of running through all Lists, compare each with another and search how many lists have the same intersection?
Best wishes Tom