I have to list of integer like {1,3,4,5,6,7} I would like to generate an array, which contains pairs from the a and b arrays, in a random order, without duplicates. For example I would like to get the following result:
c={(1,5),(3,7),(4,6),...}
and if we found odd numbers, then it should give us any random selection for that last number
{1,3,4,5,6,7,8}
c={(1,5),(3,7),(4,6,8),...}
I have used below code to achieve this, but it's not working as expected.
int[] a={1,2,3,4,5};
int[] b={6,7};
List<int[]> list = new ArrayList<>();
for (int i = 0; i < a.length; ++i)
for (int j = 0; j < b.length; ++j)
list.add(new int[] {a[i], b[j]});
Collections.shuffle(list);
Thanks!