Skip to content

Commit d52467d

Browse files
committed
Added 1669B - Triple.cpp
1 parent 52da037 commit d52467d

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

1669B - Triple.cpp

+37
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
// ॐ नमः शिवाय
2+
#include<bits/stdc++.h>
3+
using namespace std;
4+
#define ll long long
5+
6+
// Code Written By: Vikash Patel
7+
// Codeforces Profile: https://codeforces.com/profile/vikashpatel
8+
9+
10+
int solve(int a[], int n)
11+
{
12+
unordered_map<int, int> ump;
13+
for(int i=0;i<n;i++)
14+
{
15+
ump[a[i]]++;
16+
if(ump[a[i]]==3)
17+
return a[i];
18+
}
19+
return -1;
20+
}
21+
int main()
22+
{
23+
int t;
24+
cin>>t;
25+
while(t--)
26+
{
27+
int n;
28+
cin>>n;
29+
int a[n];
30+
for(int i=0; i<n; i++)
31+
{
32+
cin>>a[i];
33+
}
34+
cout<<solve(a,n)<<endl;
35+
}
36+
return 0;
37+
}

0 commit comments

Comments
 (0)