Sir I am unable to understand the logic behind the solution provided to us in this link
Also , the other link showing the dry run of the code is not satisfactory. Please help me with the logic.
Dry run link is here
Sir I am unable to understand the logic behind the solution provided to us in this link
Also , the other link showing the dry run of the code is not satisfactory. Please help me with the logic.
Dry run link is here
@rishabh1000
See as we know that there are only two type of chars in the string, here count[0] is for ‘a’ and count[1] is for ‘b’, here 2 cases are going side by side, one is maximum len string by doing k modifications consisting of only ‘a’ and another is consisting of only ‘b’.
so whenever the minimum of both is greater than k, it means that we have converted k chars for that case and cannot convert more, so we are just reducing one occurence of it where l denotes the first character for the substring under consideration.
Thank you for the explaination. However I am still unclear about the if case.
Can u please elaborate the case where the min(freq[a],freq[b])>k?
I still have some problem in visualizing the process. I mean what actually are we thinking while performing those steps?