Sanket and Strings

Can anyone help me in the swapping part. I can traverse all the string elements but how can I perform swapping of β€˜a’ and β€˜b’. I really don’t know how to solve this problem.

Hey Saksham! first take for β€˜a’, so you have to swap only β€˜b’. Calculate the answer for β€˜a’. Now do same for β€˜b’ (as you only sway β€˜a’ now!)
eg: string input = ababb and k=2
for β€˜a’ maximum length can be 4(swap 2 b)
for β€˜b’ maximum length can be 5
so answer is 5.

Maybe You can send the code so that I can understand how to implement it and write my own code after that.

@Saksham_Agarwal For code you may refer editorial as it shares the same approach.

Where is the editorial? U are talking about the ide I guess

Not talking about ide!, Editorial/solution is given for every coding task, you can access it.

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.