Find K-th Smallest Pair Distance [Solved]

In this article, we have solved the problem of finding the K-th smallest pair distance. This involve the concept of Binary Search.

PROBLEM STATEMENT

The kth smallest distance between a pair of integers a and b can be defined as the absolute difference between a and b.

Suppose you have an array of integers called nums and an integer k. Your task is to find the kth smallest distance among all the pairs nums[i] and nums[j] where 0

EXAMPLE

Example 1:
Input: nums = [1,2,4,5,6], k = 3
Output: 1
Expla...

 •  0 comments  •  flag
Share on Twitter
Published on March 04, 2023 05:52
No comments have been added yet.