I am getting run time why?

#include
using namespace std;
int main() {
int num;
cin>>num;
char s[100];
cin>>s;
int a=0;
int b=0;
int size=0;
for (int i = 0;s[i]!=’\0’; i++)
{
if(s[i]==‘a’){
a++;
}
else{
b++;
}
size++;
}
int ans=max(a,b);
if(ans+num<=size){
cout<<ans+num;
}
else{
cout<<size;
}
return 0;
}

hi pls save ur code on ide and send.
or u can also refer this https://ide.codingblocks.com/s/589202

Didn’t understand the approach

Hi… so what i have done is taken 2 cases. as stated in question we want consecutive a’s or b’s so in one function call i am trying to find ans only by flipping a and in other function i am trying to find ans only by flipping b’s

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.