Created
November 1, 2018 20:57
-
-
Save WennderSantos/73ac7931b7f8392fcd678af85a150ebb to your computer and use it in GitHub Desktop.
RunLength. O(n)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
static void Main(string[] args) | |
{ | |
var input = "wwwwaaadexxxxxxywww"; | |
Console.WriteLine(input); | |
for (var i = 0; i < input.Length - 1; i++) | |
{ | |
var count = 1; | |
while(i < input.Length - 1 | |
&& input[i] == input[i + 1]) | |
{ | |
count++; | |
i++; | |
} | |
Console.Write($"{count}{input[i]} "); //4w 3a 1d 1e 6x 1y 3w | |
} | |
} |
Author
WennderSantos
commented
Dec 5, 2018
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment