Skip to content

Commit

Permalink
Solved for issue python-geeks#98
Browse files Browse the repository at this point in the history
  • Loading branch information
nghiab1706989 authored Oct 27, 2021
1 parent e6b562f commit f8ebc59
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 0 deletions.
4 changes: 4 additions & 0 deletions 394/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Hi, SpasZahariev! Here is my help . My code is on Python3 scenario
# Use Regex==regular expression is a sequence of characters that specifies a search pattern.


12 changes: 12 additions & 0 deletions 394/leetcode394-DecodeString.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
class Solution:
def decodeString(self, s: str) -> str:
import re
patt = "(\d+)\[([a-z]+)\]"

found = re.findall(patt, s)
while found:
for rep, cnt in found:
s = s.replace(f'{rep}[{cnt}]', cnt * int(rep))
found = re.findall(patt, s)

return s

0 comments on commit f8ebc59

Please sign in to comment.