This article is contributed by Mr.

Email Required, but never shown. How old is Julio now? For each number x in the array, test whether x-c is in the array via binary search. Related Questions Among all pairs of numbers whose difference is 8, find a pair whose product is as small as possible.? Tell me how to set up a problem like this in as simple matter as possible and work me through step by step.

## Smallest Difference pair of values between two unsorted Arrays

Julio is 4 years older than Jacqueline. Chat or rant, adult content, spam, insulting other members, show more.

Mong all pairs of numbers whose difference is 20, find a pair whose product is as small a possible. Return the difference.

If you want to be fancy, you can do it by only iterating twice through the array, but the complexity is dominated by the sorting step anyway. Recommended Posts: If we were trying to find 2 numbers, whose sum is c, then i know that there is an O nlogn solution.

Small result between. I see, thank you! Well, the value at bis bigger than the value at a, so moving b will only make the difference larger. Antimony Antimony 27. Are you sure you want to delete this answer?

Related 381. This is still O nlogn. You then want to minimize the product.

Yes No. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Stack Overflow works best with JavaScript enabled. Yahoo Answers. Best Answer: