Given a sorted array of prime numbers starting with 1, return the kth smallest fraction arr[i] / arr[j] with i < j. Use a heap to generate fractions in sorted order without enumerating all pairs.
arr = sorted prime-like array, k = rank of fraction
fraction [numerator, denominator] that is kth smallest
Example 1:
Input:
arr = [1,2,3,5] k = 3
Output:
[2,5]
Explanation:
Fractions in order are 1/5, 1/3, 2/5, 1/2, 3/5, 2/3; the 3rd is 2/5.
Example 2:
Input:
arr = [1,7] k = 1
Output:
[1,7]
Explanation:
Only one fraction exists.