Description
Given an encoded string, return its decoded string. The encoding rule is: k[encoded_string], where the encoded_string inside the brackets is being repeated exactly k times.
Examples
Input:
s = "3[a]2[bc]"Output:
"aaabcbc"Explanation:
3 copies of 'a' followed by 2 copies of 'bc'.
Input:
s = "3[a2[c]]"Output:
"accaccacc"Explanation:
Inner '2[c]' becomes 'cc', then '3[acc]' becomes 'accaccacc'.
Input:
s = "2[a3[b]c]"Output:
abbbcabbbcExplanation:
Inner '3[b]' becomes 'bbb', making the string 'abbbc'. Then '2[abbbc]' repeats this twice, resulting in 'abbbcabbbc'.
Constraints
- •
1 ≤ s.length ≤ 30 - •
s consists of lowercase English letters, digits, and '[]'.