Problems > Run-Length Encoding > Editorial

Run-Length Encoding — Solution & Editorial

Back to the Problem

Walk the string; for each position extend to the end of the current run, emit char + count, jump ahead.

Complexity: O(|S|)