Medium Accuracy: 58.64% Submissions: 100k+ Points: 4

Given an array arr[] and a number K where K is smaller than size of array, the task is to find the K^{th} smallest element in the given array. It is given that all array elements are distinct.

Input:
The first line of input contains an integer T, denoting the number of testcases. Then T test cases follow. Each test case consists of three lines. First line of each testcase contains an integer N denoting size of the array. Second line contains N space separated integer denoting elements of the array. Third line of the test case contains an integer K.

Output:
Corresponding to each test case, print the k^{th} smallest element in a new line.

Expected Time Complexity: O(N). Expected Auxiliary Space: O(1).

Constraints:
1 <= T <= 100
1 <= N <= 10^{5}
1 <= arr[i] <= 10^{5}
1 <= K <= N