Skip to content

Commit

Permalink
Time: 58 ms (39.39%), Space: 13.9 MB (71.38%) - LeetHub
Browse files Browse the repository at this point in the history
  • Loading branch information
AvAkanksh committed Nov 5, 2022
1 parent ea3a165 commit 2210bf7
Showing 1 changed file with 22 additions and 0 deletions.
22 changes: 22 additions & 0 deletions 0394-decode-string/0394-decode-string.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
class Solution:
def decodeString(self, s: str) -> str:
myList = [];
for i in s:
if(i!=']'):
myList.append(i);
else:
pattern = '';
while(myList[-1]!='['):
pattern = myList[-1] + pattern;
myList.pop();

myList.pop();
number = '';
while(len(myList)!=0 and myList[-1]<='9' and myList[-1]>='0' ):
number = myList[-1] + number;
myList.pop();

myList.append(pattern * int(number));

return ''.join(myList);

0 comments on commit 2210bf7

Please sign in to comment.