Kth smallest distance
Your task
Given an integer array nums, define the distance of a pair (i, j) as abs(nums[i] - nums[j]). Return the k-th smallest distance among all n*(n-1)/2 pairs (1-indexed). 2 <= len(nums) <= 1e4 so enumerating all pairs is too slow.
Examples
smallest_distance_pair(nums: list[int], k: int) -> intExample 1
Input
smallest_distance_pair([1, 3, 1], 1)Output
0