I have written a code for calculating max freq character of the string
///my Code
#include
using namespace std;
int maxfreq(string str)
{
int n=str.length();
int i=0;
int j=i+1;
int c;
int m=0;
char Max='\0';
while(i!=n-1)
{
while(j!=n-1)
{
int c=0;
if(str[i]==str[j])
{
c++;
j++;
}
else
{
j++;
}
}
if(c>m)
{
m=c;
if(m>Max){
Max=str[i];
}
}
i++;
}
return Max;
}
int main()
{
string str;
cin>>str;
char ch=maxfreq(str);
cout<<ch;
}
/// My code works fine on code blocks but while submitting the test cases are showing wrong . can you help me.