88. Decode a Nested Repeat String
MediumStacks
A string is encoded with the rule k[text], meaning text repeated k times. Encodings may be nested. Return the decoded string.
The input is always valid: digits appear only as repeat counts, every count is followed by brackets, and letters are lowercase.
Example 1
Input: s = "3[a2[c]]" Output: "accaccacc"
Example 2
Input: s = "2[abc]3[cd]ef" Output: "abcabccdcdcdef"
Constraints
1 ≤ s.length ≤ 301 ≤ k ≤ 300The decoded length is at most 10⁵