Hello coders, today we are going to solve **Uncle Johny CodeChef Solution** whose Problem Code is **JOHNY**.

**Task**

Vlad enjoys listening to music. He lives in Sam’s Town. A few days ago he had a birthday, so his parents gave him a gift: MP3-player! Vlad was the happiest man in the world! Now he can listen his favorite songs whenever he wants!

Vlad built up his own playlist. The playlist consists of **N** songs, each has a **unique** positive integer length. Vlad likes all the songs from his playlist, but there is a song, which he likes more than the others. It’s named “Uncle Johny”.

After creation of the playlist, Vlad decided to sort the songs in increasing order of their lengths. For example, if the lengths of the songs in playlist was {1, 3, 5, 2, 4} after sorting it becomes {1, 2, 3, 4, 5}. Before the sorting, “Uncle Johny” was on **K**-th position (1-indexing is assumed for the playlist) in the playlist.

Vlad needs your help! He gives you all the information of his playlist. Your task is to find the position of “Uncle Johny” in the sorted playlist.

**Input Format**

The first line of the input contains an integerÂ **T**Â denoting the number of test cases. The description ofÂ **T**Â test cases follows.The first line of each test case contains one integerÂ **N**Â denoting the number of songs in Vlad’s playlist. The second line containsÂ **N**Â space-separated integersÂ **A _{1}**,Â

**A**, …,Â

_{2}**A**Â denoting the lenghts of Vlad’s songs. The third line contains the only integerÂ

_{N}**K**Â – the position of “Uncle Johny” in the initial playlist.

**Output Format**

For each test case, output a single line containing the position of “Uncle Johny” in the sorted playlist.

**Constraints**

- 1 â‰¤Â
**T**Â â‰¤ 1000 - 1 â‰¤Â
**K**Â â‰¤Â**N**Â â‰¤ 100 - 1 â‰¤Â
**A**Â â‰¤ 10_{i}^{9}

**Example**

**Sample Input**

```
3
4
1 3 4 2
2
5
1 2 3 9 4
5
5
1 2 3 9 4
1
```

**Sample Output**

```
3
4
1
```

**Explanation**

In the example test there are **T**=3 test cases.

**Test case 1**

In the first test case **N** equals to 4, **K** equals to 2, **A** equals to {1, 3, 4, 2}. The answer is **3**, because {1, 3, 4, 2} -> {1, 2, 3, 4}. **A _{2}** now is on the

**3**-rd position.

**Test case 2**

In the second test case **N** equals to 5, **K** equals to 5, **A** equals to {1, 2, 3, 9, 4}. The answer is **4**, because {1, 2, 3, 9, 4} -> {1, 2, 3, 4, 9}. **A _{5}** now is on the

**4**-th position.

**Test case 3**

In the third test caseÂ **N**Â equals to 5,Â **K**Â equals to 1,Â **A**Â equals to {1, 2, 3, 9, 4}. The answer isÂ **1**, because {1, 2, 3, 9, 4} -> {1, 2, 3, 4, 9}.Â **A _{1}**Â stays on theÂ

**1**-th position.

**Solution – Uncle Johny**

**C++**

#include<bits/stdc++.h> using namespace std; int main() { int t ; cin>>t; while(t--) { int n,k; cin>>n; int arr[n]; for(int i=0;i<n;i++) { cin>>arr[i]; } cin>>k; k=k-1; int john=arr[k]; int m = sizeof(arr)/sizeof(arr[0]); sort(arr, arr+n); for(int i=0;i<n;i++) { if(arr[i]==john) cout<<(i+1)<<endl; } } return 0; }

**Python**

n = int(input()) for x in range(n): a = int(input()) b = list(map(int,input().split())) c = int(input()) d = b[c-1] b.sort() print(b.index(d)+1)

**Java**

/* package codechef; // don't place package name! */ import java.util.*; import java.lang.*; import java.io.*; /* Name of the class has to be "Main" only if the class is public. */ class Codechef { public static void main (String[] args) throws java.lang.Exception { Scanner sc = new Scanner(System.in); int T = sc.nextInt(); while (T>0) { int N = sc.nextInt(); int[] s = new int[N]; for (int i = 0; i < N; i++) s[i] = sc.nextInt(); int k = sc.nextInt(); int element = s[k-1]; Arrays.sort(s); for (int i = 0; i < N; i++) { if (s[i]==element) { System.out.println(i+1); break; } } T--; } } }

**Disclaimer:** The above Problem **(Uncle Johny)** is generated by **CodeChef** but the Solution is Provided by **CodingBroz**. This tutorial is only for **Educational** and** Learning** Purpose.