Sanket and strings

can you please provide me a hint of problem sanket and string

Hello @Namanjain123

You can linearly traverse the array and look for an element
such that next element is less than this element and the previous element (if exists) is also less then this element.

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.

Hello @Namanjain123

In this question you are given an integer k and a string of ‘a’ and ‘b’. What you need to do is that you have to replace either ‘a’ by ‘b’ or ‘b’ by ‘a’ at most k time so that you get a string of maximum length of either continuous ‘a’ or continuous ‘b’.
For example
k = 2
string = “aabababaabb”
If we replace b at index 2 and index 4, we get string of a of length 6 and 6 is the perfectness of the above string.

Here is the code