Test 87

The contest has ended

Speed . Accuracy . Efficiency

Saikat and Anurag are playing a game. In this game Saikat has been given an array of Integers.The size of the array is n. He needs to find the difference of the kth maximum element and the kth minimum element in the array. The number k will be given to him by Anurag. If he can find this he wins the game. As Saikat is not good with numbers can you please find the difference for him? :)

Input:

The first line contains an Integer 't' denoting the number of test cases. The next line of each test case consists of two Integers 'n' and 'k'. 'n' is the size of the array and 'k' denotes the kth maximum and minimum element in the array. The next line contains 'n' Integers denoting the array of Integers.

Output:

For each test case output the difference of the kth maximum and minimum element in the array and print the answer on a new line.

Constraints:

1 <= 10^9

(Here a[i] denotes a particular Integer in the array)

Example:

Input:

2

5 2

6 3 2 4 5

3 2

4 5 6

Output:

2

0

Explanation:

In case 1 ,2nd minimum element is 3 and 2nd maximum element is 5. So the answer is 5-3=2.

In case 2 ,2nd minimum element is 5 and 2nd maximum element is 5. So the answer is 5-5=0.

Rules

  • All the challenges will have a predetermined score. Score of a game is calculated using Bayesian Approximation
  • This contest will appeal to programmers who're interested in interesting algorithmic challenges, AI challenges and of course general programming
  • HackerRank admins decision will be final
  • Please refrain from discussing strategy during the contest.
  • Any case of code plagiarism will result in disqualification of both the users from the contest. We've a fairly good plagiarism detector that works at the opcode level.
  • You can code directly on our interface. We support 20 major languages. You can have a look at the environment in which we run your code