#394 - Decode String
Given an encoded string of the form k[encoded_string], return its decoded string. The rule is: the encoded_string inside the square brackets is repeated exactly k times. Nesting is allowed (e.g. 3[a2[c]] → "accaccacc"). Input is always valid: no extra spaces, brackets are well-formed, and k is a positive integer.
| Input | Output |
|---|---|
s = "3[a]2[bc]" | "aaabcbc" |
s = "3[a2[c]]" | "accaccacc" |
s = "2[abc]3[cd]ef" | "abcabccdcdcdef" |