Sanket and kartik bahiya problem


i made the code and check for multiple cases it gives the correct output but why testcases are not passed explain me and tell my mistake

https://ide.codingblocks.com/s/627212 i made the code and check for multiple cases it gives the correct output but why testcases are not passed explain me and tell my mistake

@dipeshgupta197 your code misses the case like
aabbbbbaabbbb where k=2
we try to change a here and the string becomes bbbbbbbaabbbb and if we uses the k=2 moves in the aa which are later then it becomes aabbbbbbbbbbb which is more good for us so this approach is not good
instead we can use 2 pointer approach
Coding Blocks IDE
this is the complete explanation if your dout is not still clear let me know and if clear mark it resolved

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.