Given an array A of N positive integers. Find the number of pairs of integers whose difference is equal to a given number K.
Note: (a, b) and (b, a) are considered same. Also, same numbers at different indices are considered different.
The first line of the input contains T denoting the total number of testcases. Then follows the description of testcases. The first line of each testcase contains two space separated positive integers N and K denoting the size of array and the value of K. The second line contains N space separated positive integers denoting the elements of array.
Output the number of pairs having difference equal to K in a separate line.
1 <= T <= 100
1 <= N <= 100
1 <= K <= 100
1 <= Ai <= 1000
6 4 5 8 7
1 3 1 8
Testcase 1: (6, 4), (5, 7) and (6, 8) are pairs with difference 2.
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.