2 test cases wrong

i am not able to understand where my code is getting wrong
the code is-
#include
#include
using namespace std;
int main() {
int swap;
cin>>swap;
string s;
cin>>s;
int maxlen=0;
int i,j;
for(i=0;i<s.length();i++)
{
char ch=s[i];
int temp=swap;
int len=0;
for(j=0;j<s.length();j++)
{
if(s[j]!=ch)
{
len++;
–temp;
if(temp<0)
{
break;
}
}
else
{
len++;
}
}
if(len>maxlen)
{
maxlen=len;
}
}
cout<<maxlen;
return 0;
}

hey @pragyachoudhary1111, there are some logic errors in ur code, can we first discuss the logic?