Coding Trainer

Find K Pairs with Smallest Sums

MediumTop K / HeapLC #373

Problem

Given two sorted arrays nums1 and nums2, return the k pairs (u,v) with the smallest sums.

Example: nums1=[1,7,11], nums2=[2,4,6], k=3 → [[1,2],[1,4],[1,6]]