You have two arrays, a and b
Both contain n elements, all positive and distinct.
you have to create a pair, by taking one number from each array, such that the sum of the differences of the pairs are minimized.
for example, a = [1, 2, 3], b = [4, 5, 6]
one possible set of pairs = (1, 4), (2, 5), (3, 6)
sum of differences = |1 – 4| + |2 – 5| + |3 – 6| = 9
And now the sum of the differences has to be as small as possible
Desing an algorithm that those this is O(nlogn) time
So far, I have sorted both these arrays. I am unsure how to proceed now