Find K pairs with the smallest sums

0
Remix

Given two sorted arrays and k, return the k pairs (one number from each array) with the smallest sums. Start a min-heap with pairs formed from the first elements and push the next candidate each time you pop, instead of building every pair.

AppleGoogleMetaTechnical phone screenLast asked Dec 2025
No answer yet. Write the first one; the best answer gets endorsed.