Loading...
Loading...
Loading...
A text uses the form k[text] to mean that text is repeated k times. These forms can be nested. Decode the text. Letters outside brackets stay as they are. k is a positive whole number.
Example 1
Input
3[a]2[bc]
Output
aaabcbc
aaabcbc.
Example 2
Input
2[a2[c]]
Output
accacc
Try the problem first. Open one hint at a time.
On [ save the text built so far and the number before it on the stack.
On ] pop them and repeat the current text.
Write your Python code, run it on the examples and submit it to hidden tests.
Solve in the editor