394. Decode String
![17368230-0448f6be9ebdcc30.png](https://i-blog.csdnimg.cn/blog_migrate/5f30a49227755afc62bf9376eaf99bc7.webp?x-image-process=image/format,png)
394. Decode String
class Solution(object):
def decodeString(self, s):
"""
:type s: str
:rtype: str
"""
stack = []
for i in s:
if i != ']':
stack.append(i)
else:
temp = []
while stack[-1] != '[':
t = stack.pop()
temp.append(t)
temp = temp[::-1]
stack.pop()
n_l = []
while stack and stack[-1] in '1234567890':
n_l.append(int(stack.pop()))
n_l = n_l[::-1]
n = 0
for i in n_l:
n = n * 10 + I
stack.extend(n*temp)
return ''.join(stack)