Unable to understand approach

I understand the question but i am unable to find a way to approach. Please suggest something or give some hints

Hello @ankush.bhardwaj0,

You can implement the following approach:
Perform following for both the characters a and b individually,

  1. Take two pointer l and r to mark the left and right index of the string under consideration.
  2. starting from l=0,r=0,max=0,count=0.
  3. repeat untill r <n
    3.1. increase the count whenever you find a different character(by different we mean if we are forming a string of a only, then b is different).
    3.2. while count is greater than k,
    3.2.1. decrement the count by one if element at lth index is different.
    3.2.1. increment l.
    3.3. Compare max with count for maximum value.
    3.4. increment r.

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

@S18ML0016 What is the n that u have given??

n is the length of string

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.