My issue
I am getting wrong answer for this questions please help me in solving this question
My code
#include <bits/stdc++.h>
using namespace std;
int main() {
// your code goes here
int i,j,k,l,m,n;
int max;
max=INT_MIN;
l=1;
cin>>i;
for (j=0;j<i;j++)
{
string s;
cin>>s;
sort(s.begin(),s.end());
for (k=0;k<s.size();k++)
{
if (s[k]==s[k+1])
{
l=l+1;
if (l>max)
{
max=l;
}
}
else
{
l=1;
}
}
n=s.size()-max;
if (max==n)
{
cout<<"YES"<<"\n";
}
else
{
cout<<"NO"<<"\n";
}
max=INT_MIN;
l=1;
}
return 0;
}
Problem Link: LCH15JAB Problem - CodeChef