Timer is Running

Easy Query
Submissions: 976   Accuracy:


  Difficulty: Medium   Marks: 4
Associated Course(s):   Geeks Classes

You are given an array A of size N and Q queries. Now for each query of the form X, Y and K, output the Kth smallest number in sub-array between X and Y. 

The first line contains integer T, denoting number of test cases. The first line of each test case contains an integer N & Q, denoting the number of elements in array A and number of query respectively. The second line of each test case contains N space separated integers denoting values of the array A. Third line of each test case contains Q queries in form X Y K.

For each test case, output Q integers in single line. where Ith integer is answer to Ith query.

1 <= T <= 20
1 <= N <= 15000
1 <= Q <= 10000
1 <= Aj <= N, 1 <= j <= N


5 2
4 1 2 2 3
1 5 2 3 5 3

2 3

** For More Input/Output Examples Use 'Expected Output' option **

Contributor: Ravi Kumar
Author: Ravi kumar

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.

Need help with your code? Please use ide.geeksforgeeks.org, generate link and share the link here.

to report an issue on this page.