 Pairs with Difference less than K
##### Submissions: 2709   Accuracy: 22.1%   Difficulty: Easy   Marks: 2

Given an array of N integers, the task is to find all pairs with difference less than K.

Input:
The first line of input contains an integer T denoting the number of test cases. Then T test cases follow. Each test case consists of two lines. First line of each test case contains two integers N & K and the second line contains N space separated array elements.

Output:
For each test case, print the count of required pairs in new line.

Constraints:
1<=T<=100
2<=N<=104
0<=K<=103
1<=A[i]<=105

Example:
Input:

2
4 3
1 10 4 2
3 5

2 3 4

Output:
2
3

Explanation:

```Input : a[] = {1, 10, 4, 2}
K = 3
Output : 2
We can make only two pairs with difference less than 3.
(1, 2) and (4, 2)```

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

Contributor: Arun Tyagi
Author: arun03

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.