My issue
plz debugging this code
My code
#include <bits/stdc++.h>
#define ll long int
using namespace std;
void sort_(map<ll,ll>mp3,ll countn){
map<ll,ll>map4;
for(auto v:mp3){
map4.insert({v.second,v.first});
}
ll ans1=1002;
for(auto v:map4){
if(v.first==countn){
ans1=min(ans1,v.second);
}
else{
cout<<ans1<<endl;
return;
}
}
}
int main() {
// your code goes here
ll t;
cin>>t;
while(t--){
ll n;
cin>>n;
vector<ll>v(n);
map<ll,ll>mp1,mp2,mp3,map4;
for(ll i=0;i<n;i++){
cin>>v[i];
}
for(ll i=0;i<n;i++){
if(v[i]=v[i+1]){
mp1[v[i]]++;
}
mp2[v[i]]++;
}
ll k=mp2.size();
ll countn=0;
for(ll i=0;i<k;i++){
ll ans=0;
ans=max(ans,(mp2[v[i]]-mp1[v[i]]));
countn=ans;
mp3[v[i]]+ans;
}
sort_(mp3,countn);
}
return 0;
}
Problem Link: RECNDNOS Problem - CodeChef