For example,
I have a 2D array of:
{ [1,2,3,4],
[2,4,6,8],
[8,7,1,5]
[0,9,3,10] }
It consists of the numbers 1,2,3,4,5,6,7,8,9,10.
In this example, you can see that no one of the elements exist on all rows. Thus, I have to pick [3,8] because these elements cover all 4 rows. Picking [1,2,3] can also cover all rows, but the minimum solution is 2 elements, which is [3,8].
I would like to do this using programmatically, using any language, preferred C++ or Java. My actual dataset is 96 unique items, on about 80 rows.
SG Test is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.