394. 字符串解码 - 力扣(LeetCode)
class Solution:def decodeString(self, s: str) -> str:stack = []num = 0curr_str = ""for char in s:if char.isdigit():num = num * 10 + int(char)elif char == '[':stack.append((curr_str, num))curr_str, num = "", 0elif char == ']':last_str, repeat = stack.pop()curr_str = last_str + curr_str * repeatelse:curr_str += charreturn curr_str