 Smallest Absolute Difference
##### Submissions: 2572   Accuracy: 34.42%   Difficulty: Medium   Marks: 4

Given an array of size n containing positive integers n and a number k,The absolute difference between values at indices i and j is |a[i] – a[j]|. There are n*(n-1)/2 such pairs and you have to print the kth smallest absolute difference among all these pairs.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case contains an integer n denoting the size of the array. Then next line contains n space separated integers forming the array. The last line contains the integer k.

Output:
Print the kth smallest absolute difference among all these pairs.

Constraints:
1<=T<=10^5
1<=N<=10^5
1<=a[i]<=10^5
1 <= k <= n*(n-1)/2

Example:
Input:

2
4
1 2 3 4
3
2
10 10
1

Output:
1
0

#### ** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ayush Govil
Author: Ayush Govil 1

If you have purchased any course from GeeksforGeeks then please ask your doubt on course discussion forum. You will get quick replies from GFG Moderators there.