Problem Statement | |||||||||||||
Uncompress the given string s in the following manner: Find a section that matches the pattern "k(q)" (quotes for clarity only), where k is a single digit, the two parentheses are a matching set, and q is zero or more characters. Replace the entire section with k consecutive occurrences of q. Repeat this process until there are no more such patterns. Return the length of the uncompressed string. | |||||||||||||
Definition | |||||||||||||
| |||||||||||||
Constraints | |||||||||||||
| - | s will contain between 0 and 50 characters, inclusive. | ||||||||||||
| - | s will contain only digits ('0'-'9') and parentheses ('(',')'). | ||||||||||||
| - | The parentheses in s will be properly matched. | ||||||||||||
| - | Each opening parenthesis ('(') in s will be preceded by a digit ('0'-'9'). | ||||||||||||
| - | The return value will be less than or equal to 2147483647. | ||||||||||||
Examples | |||||||||||||
| 0) | |||||||||||||
| |||||||||||||
| 1) | |||||||||||||
| |||||||||||||
| 2) | |||||||||||||
| |||||||||||||
| 3) | |||||||||||||
| |||||||||||||
| 4) | |||||||||||||
| |||||||||||||
| 5) | |||||||||||||
| |||||||||||||