Decode Nested Signal
Preview mode. Log in to edit, run, submit, and save progress.
Medium
Decode Nested Signal
A compressed signal uses repeat blocks. A pattern like k[text] means the text inside the brackets should be repeated k times. Blocks may be nested inside each other. Given one encoded string, return the fully decoded string.
Examples
Example 1
Input:
3[a]2[bc]
Output:
aaabcbc
Explanation: 3[a] becomes aaa and 2[bc] becomes bcbc.
Approach hint
When you see [, save the current string and repeat count.
Common mistake
Skipping assumptions, edge cases, or trade-offs can make an otherwise good answer feel incomplete.
solution.cpp