SanketAndStrings

Can you please tell me what is the error in my code?

hello @rahul_bansal
pls save ur code at cb ide and share its link with me

no this problem is not this much simple.

here u need to find the maximum length of a substring (consecutive subsequence) consisting of equal letters. and u are allowed to change no more than k characters of the original string.

for example->
4 2
abba

answer is 4 becuase can obtain both strings “aaaa”(by change 2 b’s into a) and “bbbb”(changing a’ to b)

8 1
aabaabaa
answer is 5 becuase we can obtain string “aaaaabaa” or string “aabaaaaa”. (both have 5 length substring with all smae character)

hint -> two pointers

ohh ok I understand. Thanks!!

Sir, I have solved it by the below solution can you please let me know what’s the error:

its incorrect.

3
aaaabbbbbaaaaabbbaaaa
here urs will give 7.

but if u will change this b into a then aaaaabbbaaaa
u will get 12

1 Like

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.