Decoding A String

easy
You are given a string that is encoded.
 Encoded string is like k1[(str1)](str2)k2[(str3)]k3[(str4)]....
 Here k1, k2, k3,.. are positive integers representing the frequency of the string in brackets following them.
 Integers given in the string have to be treated as frequencies only and not a part of any other string.
 Example : there is no string given to you like 2[a4d] or 3[a]2
 Brackets are always given balanced.
 You have to return the string after decoding i.e. removing all the brackets and frequencies and giving the original form of the string.

Input Format

A string

Output Format

A string

Constraints

0 <= size of string <= 1000

Notice

Try First, Check Solution later

1. You should first read the question and watch the question video.
2. Think of a solution approach, then try and submit the question on editor tab.
3. We strongly advise you to watch the solution video for prescribed approach.

Example

Input
3[a]2[bc]
Output
aaabcbc
Previous
Array With Two Stacks
Next
Largest Pair Of Smallest Elements

Related Questions