0

So I have a List of List of items Example:

List[0] : item1, item2, item3, item4, item5
List[1] : item4, item2, item3, item6, item2
List[2] : item2, item5, item7, item9, item1
List[3] : item1, item7, item6, item2, item9

Basically I try to group them and find all possible combinations. The best is find all the possible combinations of same items.

For example one of them would be

list[0] item2,
list[1] item2,
list[2] item2, 
list[3] item2.

So item2 exist in all list it is a combination. Item2 for List 0,1 and Item 7 for List 2,3 is another combination.

I tries to find all the possible combinations like this in a List of List of items.

I can't figure out any algorithm quicker than N^3. I currently have 3 for loop and going through all possible combinations. Is there a quicker way?

Thanks

huggs
  • 85
  • 1
  • 1
  • 10
  • You can see a good explanation here: [link](http://stackoverflow.com/questions/21895335/generate-a-matrix-containing-all-combinations-of-elements-taken-from-n-vectors) –  Sep 17 '15 at 22:16
  • Yeah but how to do this in Java? I dont think Java have all these methods that I can use. – huggs Sep 18 '15 at 16:55

0 Answers0