i am not getting how to approach for this question please tell me an easy method to approach for this question
Sanket and string
@royprincejmp take input k and input string
calculate length of string
take a array as count [ ]={0,0}
and two variable ans =0 and left =0
why I am taking this because In question given that there are two type of symbol a and b
iterate from 0 to length of the string
store frequency of each element
as count[a[i]-‘a’]++
now apply a check is
if(min(count[0],count[1])>k)
count[a[left]-‘a’]- -;
left++;
} else {
ans++;
}
}
cout<<ans<<endl;
and you’re done!