Problem
Submissions

Problem: Find K-th Smallest Pair Distance

Statement

Given an array of integers nums and an integer k, return the kthk^{th} smallest distance between any pair of integers (nums[i], nums[j]), where 0≤0 \leq i << j << num.length.

The distance between a pair of integers, aa and bb, is defined as the absolute difference between them.

Constraints:

  • n==n == nums.length

  • 2≤n≤1032 \leq n \leq 10^3

  • 0≤0 \leq nums[i] ≤103\leq 10^3

  • 1≤1 \leq k ≤n×(n−1)2\leq \frac{n \times (n-1)}{2}

Note: Given an array of size nn, the total number of possible pairs is given by nC2{}^{n}C_{2}. As nC2{}^{n}C_{2} evaluates to n×(n−1)2\frac{n \times (n-1)}{2}, there are exactly these much possible kk-distances.

Problem
Submissions

Problem: Find K-th Smallest Pair Distance

Statement

Given an array of integers nums and an integer k, return the kthk^{th} smallest distance between any pair of integers (nums[i], nums[j]), where 0≤0 \leq i << j << num.length.

The distance between a pair of integers, aa and bb, is defined as the absolute difference between them.

Constraints:

  • n==n == nums.length

  • 2≤n≤1032 \leq n \leq 10^3

  • 0≤0 \leq nums[i] ≤103\leq 10^3

  • 1≤1 \leq k ≤n×(n−1)2\leq \frac{n \times (n-1)}{2}

Note: Given an array of size nn, the total number of possible pairs is given by nC2{}^{n}C_{2}. As nC2{}^{n}C_{2} evaluates to n×(n−1)2\frac{n \times (n-1)}{2}, there are exactly these much possible kk-distances.