Nested run-length decoder
Decode a nested run-length encoded string. The encoding rule is k[encoded] where the bracketed substring is repeated k times; k is a positive integer (possibly multi-digit) and brackets may nest, e.g. '3[a2[bc]]' -> 'abcbcabcbcabcbc'. Plain letters appear as themselves. The input contains only lowercase letters, digits, and the brackets, and is guaranteed valid. Return the fully expanded string.
Implement
decode_string(s: str) → strExamples
in
["3[a2[bc]]"]out"abcbcabcbcabcbc"What a strong answer looks like
State your approach and its time/space complexity out loud before you optimize. Handle the edge cases (empty input, duplicates, overflow), and say why you chose this over the brute force. Green tests are the floor, not the grade.
0:00 of about 25 min
solution.py
InputExpectedGot
["3[a2[bc]]"]"abcbcabcbcabcbc"not run yetsample