I have a simple problem and I need a fast way to achieve that. Suppose I have two columns like
1 6
3 5
5 3
As you see, element 3, and 5 are there in the 2nd column, I would like to generate a new random elements in column one, such that there will be no elements in the 2nd column matched. The elements can be from 1 ->12
My approach : I have added all the elements in the 2nd column to a hash set, then I search for the elements in column one, and check if they are in the hash set, if that's true, try to generate a new random element.
I have another idea is to visualize the problem as a 1D array, remove the duplicates,..etc., but I don't want to modify any elements in the 2nd Array.