This question evaluates string parsing and manipulation skills, focusing on handling nested encodings and repetition semantics in serialized formats. Commonly asked in Coding & Algorithms interviews for Data Scientist roles, it tests reasoning about nested structures and robustness of parsing logic, representing a practical application–level problem in the domain of string processing and parsing rather than a purely theoretical exercise.
Given an encoded string, return its decoded (decompressed) form.
Use the following encoding rule:
Examples:
"3[a]2[bc]"
→ Output:
"aaabcbc"
"3[a2[c]]"
→ Output:
"accaccacc"
"2[abc]3[cd]ef"
→ Output:
"abcabccdcdcdef"
Assume:
Return the decoded string.