Consider a set A of n bottles and set B of n caps, such that each bottle in A has unique cap in B. But bottle in A and caps in B all look the same. The only comparison that can be made is pair (a,b) of a bottle in A and a cap in B and test whether the threads of a are smaller, larger or perfect with threads of b.
Give an efficient algorithm to match up all bottles with their caps.
PS: This seems like I haven't done anything to get the solution, belive me, I did. Please just give me an answer.