Test Cases showing wrong

#include
#include
using namespace std;

char Frequency(string s)
{
long long int i,j;
long long int current_count;
long long int max_count=1;
char x;
for(i=0;i<s.length()-1;i++)
{
if(s[i]==’ ')
i++;

	char ch=s[i];
	j=i+1;
	while(j<s.length() && s[i]!='0')
	{
		current_count=1;
		if(s[j]==' ')
		  j++;

		if(ch==s[j])
		{
			current_count++;
			s[j]='0';
			s[i]='0';
		}
		j++;

	}
	if(current_count>max_count)
	{
		max_count=current_count;
        x=ch;
	} 
}
return x;

}

int main() {

string s;
cin>>s;
cout<<Frequency(s);
return 0;

}

hi @Mukul-Shane-1247687648773500
refer this -->

sir test case 0 is showing wrong

@Mukul-Shane-1247687648773500
the code i shared is working fine and passing all test cases…

#include #include using namespace std; char Frequency(string s) { int i,j; int current_count=0; int max_count=0; char x; for(i=0;i<s.length();i++) { if(s[i]==’ β€˜) i++; char ch=s[i]; j=i; current_count=0; while(j<s.length() && s[i]!=β€˜0’) { if(s[j]==’ ') j++; if(s[j]==β€˜0’) j++; if(ch==s[j]) { current_count++; s[j]=β€˜0’; } j++; } s[i]=β€˜0’; if(current_count>=max_count) { max_count=current_count; x=ch; } } return x; } int main() { string s; getline(cin,s); cout<<Frequency(s); return 0; }

try this -->

hi @Mukul-Shane-1247687648773500
ur corrected code -->


It’s passing all test cases now…

I hope I’ve cleared your doubt. I ask you to please rate your experience here
Your feedback is very important. It helps us improve our platform and hence provide you
the learning experience you deserve.

On the off chance, you still have some questions or not find the answers satisfactory, you may reopen
the doubt.