Quant Memo
Coding/●●●●●

Collapse adjacent duplicate characters

Collapse every run of consecutive identical characters into a single copy of that character. Non-adjacent repeats are kept, so "aabbaa" becomes "aba", not "a".

"aaabbbccddd"  ->  "abcd"
"aabbaa"       ->  "aba"
""             ->  ""

Return the collapsed string in O(n)O(n) time.

Your answer

This one is open-ended. Work it through, then check your reasoning against the full solution.

More Coding questions