Sanket and strings


the logic inside the if condition is not clear to me.

@nirupama1
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.

If this solution seems to difficult to understand you can also do separately for both the cases.
Here i am attaching my code for that, you can refer to it if required - https://ide.codingblocks.com/s/226542

1 Like

@nirupama1 if your doubt is solved, then please mark this as resolved.

1 Like