static void GetRepeatedCount(string str, List<int> repeatedLengths, List<int> notrepeatedLengths)
{
int i = 0;
while (i < str.Length)
{
int j = i;
do
j++;
while (j != str.Length && str[j] == str[i]);
int repeatCount = j - i;
if (repeatCount >= 2)
{
repeatedLengths.Add(repeatCount);
i = j;
}
else
{
while (j != str.Length && str[j] != str[j - 1])
j++;
int nonrepeatCount = j - i;
if (j != str.Length)
nonrepeatCount--;
notrepeatedLengths.Add(nonrepeatCount);
i = j;
if (j != str.Length)
i--;
}
}
}