394. Decode String

Practice Decode String for free on NudgeCode: Medium, Stack pattern. Write it in Python or JavaScript, run the tests in your browser, and ask for a hint when you are stuck.

The input uses the rule k[text], meaning text written k times in a row. Brackets can be nested. Return the fully expanded string.

Example

s = "3[a]2[bc]"  ->  "aaabcbc"
s = "3[a2[c]]"   ->  "accaccacc"

Constraints