left
and right
boundaries for the binary search, which are the possible range of product values.left
is less than right
, perform the following steps:
a. Calculate mid
as the average of left
and right
.
b. Count the number of products less than or equal to mid
using a helper function.
c. If the count is greater than or equal to k
, update right
to mid
.
d. If the count is less than k
, update left
to mid + 1
.left
will be the kth
smallest product.