Quant Memo
Coding/●●●●

Expand a nested run-length encoded string

A compact encoding writes k[substring] to mean the substring repeated k times, and these can nest. Decode the full string.

"3[ab]2[c]"   -> "abababcc"
"2[a3[b]]"    -> "abbbabbb"

Return the fully expanded string. Repeat counts can be multi-digit; nesting can be arbitrarily deep.

Your answer

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

More Coding questions