Kth Smallest Element
Posted: 21 Nov, 2020
You are given an array of integers 'ARR' of size 'N' and another integer 'K'. Your task is to find and return 'K'th smallest value present in the array.
Note: All the elements in the array are distinct.
The first line of input contains an integer 'T' representing the number of the test case. Then the test case follows. The first line of each test case contains two space-separated integers ‘N’ representing the size of the array and ‘K’. The second line contains N space-separated integers that represent elements of the array ARR.
For each test case, print a single line that contains a single integer which is the Kth smallest element of the array. The output of each test case will be printed in a separate line.
You do not need to print anything; it has already been taken care of. Just implement the given function.
1 <= T <= 100 1 <= N <=10 ^ 4 1 <= K <= N 1 <= ARR[i] <= 10 ^ 9 Time limit: 1 sec.