Decode String

Given an encoded string, decode it. The encoding rule is: *k*[encoded_string], where the encoded_string inside the square brackets is repeated exactly k times. (e.g., `3[a2[c]]` → `accaccacc`).

Input Format

One line encoded string.

Output Format

Decoded string.

Constraints

  • All numbers are positive ints; 1 <= original length <= 10^5.

Examples

Example 1:

Input:

s = "3[a]2[bc]"

Output:

aaabcbc

Explanation:

"a" repeated 3 times and "bc" repeated 2 times.

Loading...
Decode String - Strings DSA Problem