pls check this why this code don’t satisfy all test cases
Sanket and strings
Your code is only taking cases where optimal answer takes in consideration the first element of the string in the substring. Instead you can use two pointer approach l and r. Then for every position l we will move right end r until total number of changes are less than k. Then we need to update the answer with length of this substring and move l to the right.
Hope it Helps.
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.