plzz send a good explanation to the problem
Problem of sanket and strings
Hello @ynikhil1999,
-
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 made 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 as perfectness in the question.
Hope, this would help.
Give a like, if you are satisfied.
could you plzz send me the code for this…
I am unable to do it
code along with the comments
We are not allowed to send code.
But, i have a better option:
- Try to write some code satisfying this problem:
- If you would stuck, share the code with me.
- I will guide and help you by pointing your mistakes.
Waiting for your code.
Try hard to find some approach.
i have tried hard…so now plzz be kind enough ti send me the code along with cmmnts to simplify
sir…plzz…plzz…plzz…provide me the solution
Okay, I am sharing the code:
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.