SAnket and strings problem: does sanket change only char 'a' or he can change 'b' too?

please explain the above query

Hello @hrishikeshjanjal,

Yes, you can change ‘b’ also

In this problem, you are given a string that is composed of only two characters ‘a’ and ‘b’.
Example:
abaababab

Now, you are required to print the length of the substring containing all character as same(either all ‘a’ or all ‘b’):
2 (for aa in the above-mentioned example)

But, there is a twist. You are given a number k, that specifies the maximum number of changes you can make is the input string.
Changes: replacing ‘a’ with ‘b’ or vice-a-versa.
…Suppose, k=1 (you can make at max 1 replace)
Then, replacing ‘b’ at 2nd position with ‘a’ will modify the string as:
aaaababab
So, output:
4 (for aaaa)
…if k=2 (you can make at max 2 replaces)
Then, replacing ‘b’ at 2nd position and 5th position with ‘a’ will modify the string as:
aaaaaabab
So, output:
6 (for aaaa)

The number you have to print is referred to as perfectness in the question.

Hope, this would help.
Give a like, if you are satisfied.

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.