in reply to Searching for the remaining smaller values in an array
You don’t say how many (millions of?) pairs there are, and any other seriously binding constraints upon the problem. It may well be that a straight-ahead linear search will be more than adequate ...