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