I have a list(or array) consist of n
arrays. Each array carries an arbitrary subset of integers from 0
to n-1
(numbers are not repeated within an array). An example for n=3
is:
l = [np.array([0, 1]), np.array([0]), np.array([1, 2])]
I want to pick one single number from each array as its representative, such that no two arrays have the same representative and make a list of them in the same order as arrays. In other words, the numbers picked for arrays must be unique and the whole set of representatives, will be a permutation of numbers 0
to n-1
. For above list, it would uniquely be:
representatives = [1, 0, 2]
There is a guarantee that such list of representatives exist for our list, but how do we find them. In case, there are more than one possible list of representatives, any one of them can be randomly selected.