InterviewDB Question

Smallest Difference: Find the Pair of Elements from Two Arrays with Minimum Absolute Difference

Question Details

Problem Given two integer arrays A and B, find the pair (a, b) where a is from A and b is from B such that |a - b| is minimized. Return the pair and the difference. Example: Round 1 - Coding Solve with a two-pointer approach after sorting both arrays. Follow-ups What is the time complexity of the two-pointer approach vs. brute force? Why does sorting enable the two-pointer technique here? If there are multiple pairs with the same minimum difference, how do you return all of them? How would you s…

Full Details

🔒

Unlock all Rubrik questions

Full insider details, leaked discussions, and candidate experiences.

Get full access — $100 a year, unlimited access

About This Question

This is a reported interview question from a rubrik interview during the phone round.

It covers the following topics: Two Pointers, Phone, Coding, Arrays, Onsite .