Run-Length Encoding — Solution & Editorial
Walk the string; for each position extend to the end of the current run, emit char + count, jump ahead.
Complexity: O(|S|)
Walk the string; for each position extend to the end of the current run, emit char + count, jump ahead.
Complexity: O(|S|)