Given an encoded string A consisting of lowercase English alphabets, square parentheses, and digits.
The encoding rule is X[encoded string],
where the encoded_string inside the square brackets is being repeated exactly X times.
Note that X is guaranteed to be a positive integer.
Find and return the decoded string.
Note:
Input Format
The only argument given is string A.
Output Format
Return the decoded string.
Constraints
1 <= length of the string <= 100000
For Example
Input 1:
A = "3[a]2[bc]"
Output 1:
"aaabcbc"
Input 2:
A = "3[a2[c]]"
Output 2:
accaccacc
Input 3:
A = "2[abc]3[cd]ef"
Output 2:
abcabccdcdcdef
NOTE: You only need to implement the given function. Do not read input, instead use the arguments to the function. Do not print the output, instead return values as specified. Still have a doubt? Checkout Sample Codes for more details.