Only sample test case is getting passed. What is wrong with the code?
here is my code
What is wrong in this code
Hello @pragyachoudhary1111
In this question you are given an integer k and a string of ‘a’ and ‘b’. What you need to do is that you have to replace either ‘a’ by ‘b’ or ‘b’ by ‘a’ at most k time so that you get a string of maximum length of either continuous ‘a’ or continuous ‘b’.
For example
k = 2
string = “aabababaabb”
If we replace b at index 2 and index 4, we get string of a of length 6 and 6 is the perfectness of the above string.
Here is the modified code
Dry run the above code on below test case to see how the code works
1
abbbaaabbbbb
If you still need any help, leave a reply and I will help you out.