30:00
Given two sorted arrays nums1 and nums2, find k pairs (u1, v1), (u2, v2), ..., (uk, vk) with the smallest sums.
1≤nums1.length,nums2.length≤1051 \leq \text{nums}_1.\text{length}, \text{nums}_2.\text{length} \leq 10^51≤nums1.length,nums2.length≤105
−109≤nums1[i],nums2[i]≤109-10^9 \leq \text{nums}_1[i], \text{nums}_2[i] \leq 10^9−109≤nums1[i],nums2[i]≤109
Both nums1 and nums2 are sorted in non-decreasing order.
nums1
nums2
1≤k≤1041 \leq k \leq 10^41≤k≤104
k≤nums1.length⋅nums2.lengthk \leq \text{nums}_1.\text{length} \cdot \text{nums}_2.\text{length}k≤nums1.length⋅nums2.length
Initialize: nums1=[1,7,11], nums2=[2,4,6], k=3
1
7
11
0
2
4
6
3
(0, 0)
Empty