Dsa
Two Pointers
Hard
Minimize Distance Between Pairs
You have two sorted arrays of integers, A and B. Your task is to find the minimum absolute difference between any pair of elements, one from each array. The function should read from standard input and print this minimum difference.
Example:
Input:
3
1 3 15
4
10 12 14 16
Output:
2
Explanation: The pairs (15, 14) have the minimum absolute difference of 1.
Key concepts
two_pointerssortinggreedy
Practise this out loud — free
Start a mock interview on THIS exact question — a voice AI interviewer opens with it, pushes back like a real onsite, then hands you an instant scorecard.
🎙 Practise this question now