Back to problems

Find K Pairs with Smallest Sums

Algorithm · Apple · Medium

You are given two integer arrays nums1 and nums2, both sorted in non-decreasing order, and a positive integer k. Your task is to find the k pairs (one element from nums1 and one from nums2) whose sums are the smallest among all possible pairs. A pair is formed by choosing exactly one element from nums1 and one from nums2. The sum of the pair (u, v) is defined as u + v. Return a list of exactly k such pairs, each represented as a two-element list [u, v]. The order of the…

Checking your access…