-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathp3.cpp
More file actions
45 lines (40 loc) · 1.01 KB
/
p3.cpp
File metadata and controls
45 lines (40 loc) · 1.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
#include <bits/stdc++.h>
using namespace std;
int main(){
int t;
cin >> t;
for(int k=0; k<t; k++){
int n, a[50];
cin >> n;
for(int i=0; i<n; i++){
cin>>a[i];
}
int min = -1;
set<int> s;
for(int i=n-1; i>=0; i--){
if (s.find(a[i]) != s.end())
min = i;
else
s.insert(a[i]);
}
cout << a[min] << endl;
// for(int i=0; i<n; i++){
// if(count(a, a+n, a[i]) > 1){
// cout << a[i] << endl;
// break;
// }
// }
// int m = 0, flag=0;
// for(int i=0; i<n; i++){
// for(int j=i+1; j<n; j++){
// if(a[i] == a[j]){
// cout<<a[i]<<endl;
// flag=1;
// }
// }
// if(flag==1)
// break;
// }
}
return 0;
}