Code RoomNested run-length decoder
MediumPrep Room Coding #1010

Nested run-length decoder

CodingAlgorithms & data structuresMid–Senior~25 min

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) → str
Examples
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
InputExpectedGot
["3[a2[bc]]"]"abcbcabcbcabcbc"not run yetsample