Find K Pairs with Smallest Sums
Medium · Heap & Priority Queue · about 25 minutes
Asked at LinkedIn, Google, Uber, Amazon, Microsoft.
nums1 and nums2 are both sorted ascending. Pair each value of nums1 with each value of nums2 and return the k pairs [u, v] whose totals are lowest, in any order. The tests are chosen so the k-th lowest total is never tied.