shlogg · Early preview
Md Ariful Haque @mah-shamim

K-th Smallest Prime Fraction In PHP

Binary Search on Fractions: count valid fractions and track largest fraction smaller than midpoint m, return when count matches k or adjust search range accordingly.

786. K-th Smallest Prime Fraction
Difficulty: Medium
Topics: Array, Two Pointers, Binary Search, Sorting, Heap (Priority Queue)
You are given a sorted integer array arr containing 1 and prime numbers, where all the integers of arr are unique. You are also given an integer k.
For every i and j where 0 <= i < j < arr.length, we consider the fraction arr[i] / arr[j].
Return the kth smallest fraction considered. Return your answer as an array of integers of size 2, where answer[0] == arr[i] and answer[1] == arr[j].
Example 1:

Input: arr = [1,2,3,5], k = 3
Output: [2,5]
Explanation: The fractions...