Practice Kth Smallest Product of Two Sorted Arrays
Read the task, work through the examples, and check your approach against the constraints. Use the original LeetCode task for coding and submissions.
Problem Statement
Consider one product for every pair of positions, one from nums1 and one from nums2. Both arrays are sorted and can contain negative numbers, zero, and duplicates. Return the product at the 1-based position k after sorting this multiset of products; equal products retain their multiplicity. Practice approach: Binary-search the answer value. For each value in the first array, count how many entries of the second produce a product at most the candidate. Positive multipliers give a qualifying prefix, negative multipliers a suffix, and zero qualifies all or none. Binary-search those boundaries using wide-integer multiplication to avoid rounding errors. Choose the smallest candidate whose count reaches k.
Source: Kth Smallest Product of Two Sorted Arrays on LeetCode. Use the original task for its coding environment and submissions.
Examples
# Example 1
nums1 = [2,5], nums2 = [3,4], k = 2
8
# Example 2
nums1 = [-4,-2,0,3], nums2 = [2,4], k = 6
0
# Example 3
nums1 = [-2,-1,0,1,2], nums2 = [-3,-1,2,4,5], k = 3
-6
Constraints
Related LeetCode Problems
Practice more problems similar to Kth Smallest Product of Two Sorted Arrays.
Review your practice with PhantomCodeAI
After trying the problem yourself, use the app to discuss your approach, complexity, and edge cases.