Problem
A string is encoded with the rule k[text], which means text repeated `k` times. Encodings can be nested, like 3[a2[c]]. Return the decoded string.
Example 1
- Input
- s = "3[a]2[bc]"
- Output
- "aaabcbc"
Example 2
- Input
- s = "3[a2[c]]"
- Output
- "accaccacc"
Example 3
- Input
- s = "2[abc]3[cd]ef"
- Output
- "abcabccdcdcdef"
Constraints
1 <= s.length <= 30s contains lowercase letters, digits and square brackets.s is always valid; digits only appear as repeat counts, and 1 <= k <= 300.The decoded string is at most 10^5 characters long.