i had successfully submitted this question using my approach but when i opened the editorial i understood the concept they used but was unable to understand the code mainly the frequency array part.
here is the editorial code
#include
using namespace std;
int main() {
char str[1000];
int freq[256];
cin>>str;
for(int x=0;str[x]!='\0';x++){
freq[str[x]]++;
}
int ans=0;
char ch;
for(int x=0;x<256;x++){
if(freq[x]>0){
if(freq[x]>ans){
ans=freq[x];
ch=char(x);
}
}
}
cout<<ch;
}
please explain this to me and also tell how can a character be the index of an array