Skip to content

Commit 1a853e4

Browse files
authored
Create 45_codechef_uncle_johny.cpp
1 parent 930a9f0 commit 1a853e4

File tree

1 file changed

+46
-0
lines changed

1 file changed

+46
-0
lines changed

45_codechef_uncle_johny.cpp

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
//
2+
// main.cpp
3+
// lecture 45
4+
//
5+
// Created by Prince Kumar on 25/07/19.
6+
// Copyright © 2019 Prince Kumar. All rights reserved.
7+
//
8+
// codechef question --** Uncle johny ** ---- //
9+
10+
11+
#include <iostream>
12+
#include <vector>
13+
#include <algorithm>
14+
using namespace std;
15+
int main()
16+
{
17+
int T; cin>>T;
18+
while(T--)
19+
{
20+
int n; cin>>n;
21+
vector<int> v;
22+
for(int i=0;i<n;i++)
23+
{
24+
int x; cin>>x;
25+
v.push_back(x);
26+
// v.push_back(cin);
27+
}
28+
int k; cin>>k; // index of jhony unle song
29+
// vector use --> indexing start from 0
30+
int val = v[k-1]; // uncle jhony
31+
sort(v.begin(),v.end());
32+
for(int i=0;i<n;i++)
33+
{
34+
if(v[i]==val)
35+
{
36+
cout<<i+1<<endl;
37+
break;
38+
}
39+
}
40+
}
41+
}
42+
43+
44+
45+
46+

0 commit comments

Comments
 (0)