We have two arrays X
and Y
of n
characters each, where X
has n
randomly ordered characters, while Y
has exactly the same n
characters but in
different order.
Your task is to find a way to group the cells of the array X
and Y
into pairs that hold the same character.
For example:
Input:
X = ['O', 'L', 'M', 'S', 'N', 'J', 'P', 'T', 'I', 'R', 'H', 'G']
Y = ['S', 'N', 'H', 'P', 'T', 'I', 'O', 'R', 'L', 'M', 'G', 'J']
Output:
X[0] with Y[6]
X[1] with Y[8]
X[2] with Y[9]
X[3] with Y[0]
… and so on