Run-Length Decoder 2.0

Hard
string stack parsing recursion
Problem Description

Decode a complex run-length encoded string that supports nested patterns. Format: "a3b2(c2d)3" means "a" repeated 3 times, "b" repeated 2 times, then "(c2d)" pattern repeated 3 times, where c2d means "c" twice followed by "d".

Input Format
A single encoded string with letters, numbers, and parentheses.
Output Format
The decoded string.
Constraints
• 1 ≤ encoded string length ≤ 1000
• Numbers are 1-9 (single digit)
• Parentheses can be nested
• Letters are lowercase a-z
• Valid input guaranteed
Sample Input/Output
Input:
a3b2(c2d)3
Output:
aaabbccdccdccd
Explanation

a3 → "aaa", b2 → "bb", (c2d)3 → "ccd" repeated 3 times → "ccdccdccd". Final: "aaabbccdccdccd".

Solution Hints
135
Points
3000ms
Time Limit
256MB
Memory Limit
Code Editor
Register to Submit
Register to Access Code Editor

Create a free account to solve coding problems and track your progress.

Register Now
Feedback