My issue
i have tried to take the whole input in one vector .then calculated the most frequency of the vec . Can anyone tell why it is not passing all the testcase ?
My code
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int t ;
cin>>t ;
while(t--){
// vector<int> d ;
int m = 1 , c =1 ;
int n ;
cin>>n ;
vector<int> a(n*2) ;
for(int i=0 ; i<(n*2) ; i++){
cin>>a[i];
}
sort(a.begin(), a.end());
for(int i=0 ; i<(n*2) ; i++){
if(a[i]==a[i-1]){
c++ ;
}
else {
c = 1 ;
}
if(c>m){
m = c ;
}
}
cout<<m<<endl ;
}
return 0;
}
Problem Link: AIRM Problem - CodeChef