394字符串解码
class Solution:
def decodeString(self, s):
stack = []
for string in s:
if string != ']':
stack.append(string)
else:
tmp = ''
while stack[-1] != '[':
tmp = stack.pop() + tmp
stack.pop()
times = ''
while stack and stack[-1].isdigit():
times = stack.pop() + times
times = int(times)
tmp = ''.join(tmp) * times
stack.append(tmp)
return ''.join(stack)