Given a sorted array A of size n and a number k, return the number of unique pairs which have a difference of k.
|arr[i] - arr[j]| = k where i < j
A: [1, 3, 5, 7, 10]
k: 2
Answer: 3
A: [1, 3, 5, 7, 10]
k: 3
Answer: 1
A: [1, 3, 5, 7, 10]
k: 1
Answer: 0
The first line contains an integer âTâ denoting the number of test cases.
For each test case, the input contains two lines:
For each test-cases, the output is an integer denoting the number of k-diff pairs.
3
5 2
1 3 5 7 10
5 3
1 3 5 7 10
5 1
1 3 5 7 10
3
1
0
1 <= T <= 100
1 <= n <= 104
0 <= k <= 105
1 <= Ai <= 105