Skip to content

Commit 56e7db4

Browse files
authored
Update decrypt-string-from-alphabet-to-integer-mapping.py
1 parent f8da7d1 commit 56e7db4

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

Python/decrypt-string-from-alphabet-to-integer-mapping.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,3 +45,20 @@ def alpha(num):
4545
result.append(alpha(s[i]))
4646
i -= 1
4747
return "".join(reversed(result))
48+
49+
# Time: O(n)
50+
# Space: O(n)
51+
import re
52+
53+
54+
# regex solution
55+
class Solution3(object):
56+
def freqAlphabets(self, s):
57+
"""
58+
:type s: str
59+
:rtype: str
60+
"""
61+
def alpha(num):
62+
return chr(ord('a') + int(num)-1)
63+
64+
return "".join(alpha(i[:2]) for i in re.findall(r"\d\d#|\d", s))

0 commit comments

Comments
 (0)