how to think solution? cant approach the solution
Sanket and strings
@dhairya16 you can solve this problem with help of two pointers. Let the first pointer be l and the second pointer be r. Then for every position l we will move to right end r until on the substring si,si + 1… sr it is possible to make no more than k swaps to make this substring perfect. Then we need to update the answer with length of this substring and move l to the right. You can refer this code for implementation https://ide.codingblocks.com/s/191713
Please mark your doubt as resolved if you are satisfied.
cant understand if part, how it solves when count increases k
@dhairya16 when count is more than k we cannot make any more swaps and that’s when we know we have a potential answer
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.