Find K-th Smallest Pair Distance

Hard · Binary Search · about 30 minutes

Asked at Google, Amazon, Meta, Microsoft.

The distance of a pair (a, b) is |a - b|. Given nums and k, return the k-th smallest distance among all pairs nums[i], nums[j] with i < j.

Related guides