Decode String LeetCode solution in Python
1class Solution:2def decodeString(self, s: str) -> str:3stk = []45for i in range(len(s)):67if s[i] != "]":8stk.append(s[i])9else:10strr = ""11while stk[-1] != "[":12strr = stk.pop() + strr13stk.pop()1415num = ""16while stk and stk[-1].isdigit():17num = stk.pop() + num1819stk.append(int(num) * strr)2021return "".join(stk)