题目:
题解:
class Solution:def decodeString(self, s: str) -> str:def dfs(s, i):res, multi = "", 0while i < len(s):if '0' <= s[i] <= '9':multi = multi * 10 + int(s[i])elif s[i] == '[':i, tmp = dfs(s, i + 1)res += multi * tmpmulti = 0elif s[i] == ']':return i, reselse:res += s[i]i += 1return resreturn dfs(s,0)