BETA

Submissions : 242 Accuracy :

21.07

Stable Sort and Position
       

Given an array of n integers which may contain duplicate elements, an element of this array is given to us, we need to tell the final position of this element in the array, if a stable sort algorithm is applied.(Index of the number is given as idx)

Input:
The first line of input contains an integer T denoting the number of test cases. Each test case contains two integers n and idx. Next line contains space separated n elements in the array a[].

Output:
Print the index(0 based indexing) of the element after a stable sort operation. 

Constraints:
1<=T<=100
1<=n<=1000
0<=idx 1<=a[i]<=10000

Example:
Input:

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

Output:
4

**For More Examples Use Expected Output**


Contributor: Shashwat Jain

Set Default Code

					   
Result:
It is recommended to test your code before clicking 'Submit' button!



                   



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