Code gives wrong output

#include <bits/stdc++.h>

using namespace std;

int main()
{
char a[]=“abbceddd”;
int k = 3;
int len=-1;
int i=0;
int cnt=0;
int freq[26]={0};
for(int j=0;j!=’\0’;j++)
{
int x = freq[a[j]-‘a’];
x++;
if(x==1)
{
cnt++;
}

    while(cnt>k)
    {
        freq[a[i]-'a']--;
        if(freq[a[i]-'a']==0)
        {
            cnt--;
        }
        i++;
    }
    
     if(cnt==k)
    {
        len=max(len,j-i+1);
    }
}

cout<<len;



return 0;

}

hi @tarunkumar08yadav please share the code in some online ide (save and send me the link here)

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.