and how to do this sanket and strings question, just give a hint
Whats a substring? take example(abc)
Hello @sktg99,
-
A substring is a contiguous sequence of characters within a string.
Example:
abc
“”,a, b,c,ab,bc,abc are all sub-strings of the string abc. -
Following is the approach for this problem:
- We check for maximum length of sub-string that can be formed by every character in a set of 2 characters ( ‘a’ and ‘b’).
- For doing this we traverse whole string and whenever we find a different character, we increase the count.
- If count becomes greater than k (at right index), we again start from 0th index and if we found different character we will decrease the count.
- When count will be equal to k (at left index) then at that point the length will be rightIndex-leftIndex+1.
- We repeat this process until we reach at the end of string and at that point we will return the maximum length.
- We do this for both characters and finally return the maximum length.
Hope, this would help.
Give a like, if you are satisfied.
I have done the same thing, can u pls find the error in it
first im checking for ‘a’ then for ‘b’
Hello @sktg99,
I would reply you on the other thread that you have raised for the same doubt.
You can mark this one as resolved.
I can see some cases are fixed yet and also im not able to correct it completely, pls help me to correct this code,
this question is sanket and strings
It is working correctly.
Try to run it once again.
Mark this doubt as resolved and i won’t mind a like.
can u give me your whatsapp number pls?
i just sent you a msg on whatsapp…my name is sanchit and my number ends with 8786, pls save it in your phone

