Last active
October 6, 2022 10:26
-
-
Save oreillyross/1b33d2d3409207bd5725851474d62ef6 to your computer and use it in GitHub Desktop.
uncompress solution in python
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def uncompress(s): | |
res = [] | |
i = 0 | |
for j in range(len(s)): | |
if s[j].isdigit(): | |
continue; | |
times = int(s[i:j]) | |
res.append(s[j] * times) | |
i = j + 1 | |
return ''.join(res) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment