#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,a,b) for(ll i=a;i<b;i++)
void calculation(ll n,ll x)
{
ll i,arr[n],k,max=INT_MIN,j=0,min=INT_MAX;
map<ll,ll> m1,m2;
rep(i,0,n)
{
cin>>arr[i];
m1[arr[i]]++;
}
if(x==0)
{
rep(i,0,n)
{
if(m1[arr[i]]>max)
max=m1[arr[i]];
}
cout<<max<<" 0\n";
}
else{
rep(i,0,n)
{
if(m1[arr[i]]+m2[arr[i]]>=max && m2[arr[i]]<min){
max=m1[arr[i]]+m2[arr[i]];
min=m2[arr[i]];}
}
cout<<max<<" "<<min<<"\n";
}
}
int main ()
{
ll t,n,x;
cin>>t;
while(t--)
{
cin>>n>>x;
calculation(n,x);
}
return 0;
}
In the above code i used to map,one to store the intial frequency of numbers and second to store the frequency of numbers xor 'X'. This question is from codechef september long challenge and giving wrong answer.I am not asking answer ,but I want to clear my concepts of maps . Also I am providing the link of question if anyone want to try it. https://www.codechef.com/SEPT21C/problems/PALINT
if the key is same ,then if we increment in map 2,does it also get incremented in map 1.
pls help !. I got stuck here.