373. Find K Pairs with Smallest Sums
You are given two integer arrays nums1
and nums2
sorted in ascending order and an integer k
.
Define a pair (u, v)
which consists of one element from the first array and one element from the second array.
Return the k
pairs (u1, v1), (u2, v2), ..., (uk, vk)
with the smallest sums.
Example 1:
Example 2:
Example 3:
Constraints:
nums1.length
, nums2.length
<= 105nums1[i]
, nums2[i]
<= 109nums1
and nums2
both are sorted in ascending order.k
<= 104