Doubt regarding the editorial code

in the countMaxWindowsSize function why is the part
if(j<s.size()-1 && s[i-1]!=ch)
{
j++;
}

written??

@Manvik-Arya-4391661007540658 send the whole editorial code in the ide link so that i can look

@Manvik-Arya-4391661007540658 its written
If the char at previous position of left pointer was not ch, then that position must have counted as a swap earlier. Now we have a free swap available. Iterate right pointer forward to use that one free swap