Skip to content

Commit f8ebc59

Browse files
Solved for issue python-geeks#98
1 parent e6b562f commit f8ebc59

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

394/README.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Hi, SpasZahariev! Here is my help . My code is on Python3 scenario
2+
# Use Regex==regular expression is a sequence of characters that specifies a search pattern.
3+
4+

394/leetcode394-DecodeString.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
class Solution:
2+
def decodeString(self, s: str) -> str:
3+
import re
4+
patt = "(\d+)\[([a-z]+)\]"
5+
6+
found = re.findall(patt, s)
7+
while found:
8+
for rep, cnt in found:
9+
s = s.replace(f'{rep}[{cnt}]', cnt * int(rep))
10+
found = re.findall(patt, s)
11+
12+
return s

0 commit comments

Comments
 (0)