Find the k-th smallest fraction formed by choosing two numbers from a sorted prime array, where the numerator must come before the denominator.
K-th Smallest Prime Fraction
gfgYou are given a strictly increasing array of positive integers arr, where arr[0] = 1 and the remaining values are prime numbers.
Consider all fractions of the form arr[i] / arr[j] such that 0 <= i < j < arr.length.
Your task is to return the fraction that is the k-th smallest when all such fractions are ordered from smallest to largest.
arr in strictly increasing order.k representing the rank of the target fraction among all valid fractions arr[i] / arr[j] with i < j.[numerator, denominator] corresponding to the k-th smallest valid fraction.arr[0] = 1arr is strictly increasing1 <= k <= n(n-1)/2, where n = arr.lengthExample 1
Input
arr = [1, 2, 3, 5], k = 3
Output
[2, 5]
Explanation
The valid fractions are 1/5, 1/3, 2/5, 1/2, 3/5, and 2/3. Sorted in increasing order, the 3rd smallest is 2/5.
Example 2
Input
arr = [1, 7], k = 1
Output
[1, 7]
Explanation
There is only one valid fraction, so it is automatically the 1st smallest.
Premium problem context
Premium adds guided hints, editorial links, similar variants, discussion resources, and concept maps so you can understand why a problem matters, not just solve it once.