The problem name is ‘Dominant Element’. I did not understand the vector function in the problem. Please anyone explain that part.
include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t;
cin>>t;
while(t–){
int n;
cin>>n;
int a[n];
for(int i=1;i<=n;i++){
cin>>a[i];
}
vector count(n+1,0);
for(int i=1;i<=n;i++){
count[a[i]]++;
}
sort(count.begin(),count.end());
if(count[n]!=count[n-1])
cout<<“yes”<<endl;
else
cout<<“no”<<endl;
}
return 0;
}