i solve first 3-4 question but after that i did not know how can i solve this question
i think about question i release , i not able to solve this question . tell me what can i do
Solving approach
Hey @khemchandrs
Sanket has a string consisting of only a and b as the characters. Sanket describes perfectness of a string as the maximum length substring of equal characters. Sanket is given a number K which denotes the maximum number of characters he can change. Find the maximum perfectness he can generate by swapping no more than k characters.
Basically, there is a string which consists of only a and b. A substring is a contiguous sequence of characters within a string. Our aim is to generate substrings of a and b by swapping characters such that the lengths of substrings of either a or b is maximum possible. The only constraint we have here is that only k swaps are allowed. So, you have to tell the maximum possible length of the substrings that can be generated. By swapping, we mean that a can be replaced by b and b can be replaced by a.
For example:
Consider the following string: abba and k = 2
So, we can make only two swaps
abba (swaps = 0)
aaba (swaps = 1)
aaaa (swaps = 2)
Thus, the maximum length of substring is 4.
Consider the string: ababab and k=2
ababab (swaps = 0)
aaabab (swaps =1)
aaaaab (swaps = 2)
Thus, the maximum length of substring is 5.
Hope this helps.
swaping the a or b character have many possiblility how can i start the code
We cannot tell you about the code, we are only supposed to give you the hints.
I have given the detailed description of the problem.
but i give lot of time but question problem not solve by me
Come back to this question after solving some more problems, meanwhile, you can make progress with other questions of the course.
Sorry, we are not allowed to give the codes of solutions.
Hope this helps.
why are you not provided code?
Because we are only allowed to give hints and not allowed to give the whole codes as solutions. This will hinder your learning process.
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.