Strings-Max Frequency Character

some test cases are not cleared and i am not getting where this code is failing

#include
#include
using namespace std;
int main() {
char s1[1001];
cin>>s1;
int l1=strlen(s1);
int freq[26]={0};
for(int i=0;i<l1;i++)
{
freq[s1[i]-‘a’]++;
}
int c=0;
char d;
for(int i=0;i<l1;i++)
{
if(c<=freq[i])
{
c=freq[i];
d=s1[i];
}
}
cout<<d;
return 0;
}

@MG7
Try this testcase :
Input:
zzzccffbbneazzzzzz

Expected Output :
z

Your Output :
f

The reason for this is the mapping you are doing. Try dry running a testcase and look whether you should really assign s1[i] to d or something else maybe.

thanks for help it has pass all the testcases