sir i got this code from the editorial and i have some doubts in this problem. when i submit this code then this does not passes some test cases.
in line no 27 i have written
for(j; j<=s.length()-1 && c<=k; ++j)
but when i submit this then it does not pass all test cases but if i remove inequality from this line that is instead of writing <= when we write only < then it passes all test cases.
also in line no 36 i have the same problem. why we have to write only <. <= should be there. line 36 -
while(s[j+1]==ch && j<=s.length()-1)
i have the same problem in line no 41 -
if(j<=s.length()-1 && s[i-1]!=ch)
here also why are we using only <. why there is no <= ?
can somebody please explain me the complete while loop?
while(i<j)
{
while(s[j+1]==ch && j<=s.length()-1)
++j;
int currentLength = j-i+1;
ans = max(currentLength, ans);
++i;
if(j<=s.length()-1 && s[i-1]!=ch)
++j;
}
i am not able to understand after the increementation of i ?
here is my code -