Your question is Closest Pair Between Two Arrays. Start with the requirements on the right.
Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.
C-edge's transaction monitoring pipeline receives two unsorted arrays of integer values from separate processing stages. Given arrays a and b, find one value from each array whose absolute difference is as small as possible.
Return the pair as [x, y], where x comes from a and y comes from b. If multiple pairs have the same minimum difference, return the lexicographically smallest pair: choose the smaller x, then the smaller y.
Implement closest_pair(a, b).
a and b.[x, y] such that x belongs to a, y belongs to b, and abs(x - y) is minimal.def closest_pair(a, b):