Tap here to switch tabs
Problem
Ask
Submissions

Problem: Kth Smallest Product of Two Sorted Arrays

hard
40 min
Explore how to efficiently find the kth smallest product formed by pairs from two sorted arrays, including negative and positive values. Understand problem constraints and implement solutions using modified binary search techniques to solve complex product selection problems.

Statement

You are given two sorted 00-indexed integer arrays nums1 and nums2, along with an integer k.

Consider all possible products formed by nums1[i] * nums2[j], where i ranges over all valid indices of nums1 and j ranges over all valid indices of nums2. Return the kthk^{th} smallest product among all such pairs, using 11-based indexing.

Note: Both nums1 and nums2 are sorted in non-decreasing order. The arrays may contain negative numbers and zero, so the products can be negative, zero, or positive.

Constraints:

  • 11 \leq nums1.length, nums2.length 5×104\leq 5 \times 10^4

  • 105-10^5 \leq nums1[i], nums2[j] 105\leq 10^5

  • 11 \leq k \leq nums1.length ×\times nums2.length

  • nums1 and nums2 are sorted in non-decreasing order

Tap here to switch tabs
Problem
Ask
Submissions

Problem: Kth Smallest Product of Two Sorted Arrays

hard
40 min
Explore how to efficiently find the kth smallest product formed by pairs from two sorted arrays, including negative and positive values. Understand problem constraints and implement solutions using modified binary search techniques to solve complex product selection problems.

Statement

You are given two sorted 00-indexed integer arrays nums1 and nums2, along with an integer k.

Consider all possible products formed by nums1[i] * nums2[j], where i ranges over all valid indices of nums1 and j ranges over all valid indices of nums2. Return the kthk^{th} smallest product among all such pairs, using 11-based indexing.

Note: Both nums1 and nums2 are sorted in non-decreasing order. The arrays may contain negative numbers and zero, so the products can be negative, zero, or positive.

Constraints:

  • 11 \leq nums1.length, nums2.length 5×104\leq 5 \times 10^4

  • 105-10^5 \leq nums1[i], nums2[j] 105\leq 10^5

  • 11 \leq k \leq nums1.length ×\times nums2.length

  • nums1 and nums2 are sorted in non-decreasing order