← 返回 google 的题目列表Decode String
类型:online_judge
Decode String
Given an encoded string s, decode it using the following rules:
k[encoded_string] means that encoded_string is repeated exactly k times.
k is a positive integer and may contain multiple digits.
Encodings may be nested.
Return the decoded string.
Example 1
Input: s = "3[a]2[bc]"
Output: "aaabcbc"
Example 2
Input: s = "3[a2[c]]"
Output: "accaccacc"
Example 3
Input: s = "2[abc]3[cd]ef"
Output: "abcabccdcdcdef"
Constraints
1 <= len(s) <= 30
s consists of lowercase English letters, digits, and square brackets.
The input is guaranteed to be valid.
The decoded string has length at most 10^5.
Example
Input
3[a]2[bc]
Output
aaabcbc