Problem statement

https://binarysearch.com/problems/Run-Length-Decoding/

Solution

Go symbol by symbol and if we have digit, update num, if we have letter, add this letter multiplied by num.

Complexity

It is O(m) for time and space, where m is the length of answer.

Code

class Solution:
    def solve(self, s):
        ans, num = [], ""
        for x in s:
            if x.isdigit():
                num += x
            else:
                ans += [x] * int(num)
                num = ""
        return "".join(ans)