Find K Pairs with Smallest Sums (LeetCode 373).
Asked in the DSA round 1 stage. Given two ascending sorted integer arrays, return up to k pairs [nums1[i], nums2[j]] with the smallest sums. Preserve duplicate pairs and return them in nondecreasing sum order.
Implement k_smallest_pairs(nums1, nums2, k). Return a list containing at most k pairs. Return [] when either array is empty or k is zero.
def k_smallest_pairs(nums1, nums2, k):