pls can i get a hint how to solve the question
Logic to solve the qstn
hello @Senjuti256
hint -> two pointer approach.
ou can implement the following approach:
Perform following for both the characters a and b individually,
Take two-pointer l and r to mark the left and right index of the string under consideration.
starting from l=0,r=0,max=0,count=0.
repeat until r <n
3.1. increase the count whenever you find a different character(by different we mean if we are forming a string of an only, then b is different).
3.2. while count is greater than k,
3.2.1. decrement the count by one if the element at lth index is different.
3.2.1. increment l.
3.3. Compare max with count for maximum value.
3.4. increment r.
pls help me to debug it as 2 TC are failing.
use ans variable to store maximum answer encounter so far.
beg and end will keep on updating so it need not hold max string index all the time
is this called the sliding window technique?