Working of Second loop

while (i < j)

{
    while (j < s.size() - 1 && s[j + 1] == ch){
        j++;
    }

    int currentLength = j - i + 1;

    ans = max(ans, currentLength);

    i++;

    if (j < s.size() - 1 && s[i - 1] != ch)
        j++;
}
return ans;

}

can you please explain what’s the second loop doing .
and you please refer a video for it

@sinhadivyam19
second while loop is for just moving the index j.
for eg if ch==‘a’ then do j++ until next index i.e. j+1 is equal to ch.
so it will cover all the consecutive index having character as ch.

If you have any further doubt in this, then please write the code and share its ide link.
If it is clear now, then please mark this doubt as resolved.

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.