public static void Main()
Console.WriteLine(GetConsecutiveGroups("aaaabbccaa"));
private static string GetConsecutiveGroups(string input)
var result = new StringBuilder();
var sb = new StringBuilder();
if (sb.Length == 0 || sb[sb.Length - 1] == c)
result.Append($"{sb.Length}{sb[0]}");
result.Append($"{sb.Length}{sb[0]}");
return result.ToString();