Decode String
Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times.

30:00

Decode String
medium
Topics
Companies

Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the square brackets is being repeated exactly k times.

Example 1:
Input: "3[a]2[bc]"
Output: aaabcbc
Constraints:
  • 1s.length301 \leq s.\text{length} \leq 30

  • s consists of lowercase English letters, digits, and [/].

  • s is a valid encoded string and the encoded count k satisfies 1k3001 \leq k \leq 300.

Input
arr ="3[a]2[bc]"

Decode string: "3[a]2[bc]"

Input String
3
[
a
]
2
[
b
c
]
Stack (bottom to top)

Empty

Current String

""

Current Number

0

Result: ""

Variables
No variables to display
DepthFunction Call
Stack empty
0/10