Sanket and string

https://hack.codingblocks.com/contests/c/537/1569
CAN SOME PLEASE EXPLAIN HOW TO APPROACH THE QUESTION ,I AM NOT ABLE TO FIGURE OUT

Hey Ankit, this problem can be solved with help of two pointers. Let the first pointer is l and the second pointer is r. Then for every position l we will move right end r until on the substring slsl + 1… sr it is possible to make no more than k swaps to make this substring beautiful. Then we need to update the answer with length of this substring and move l to the right.

1 Like